Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
finally fixed #110
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Sep 10, 2018
1 parent ab807be commit 7ea7758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions uproot/rootio.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import keyword
import numbers
import os
import re
import struct
import sys
Expand All @@ -52,12 +53,14 @@
################################################################ high-level interface

def open(path, localsource=MemmapSource.defaults, xrootdsource=XRootDSource.defaults, httpsource=HTTPSource.defaults, **options):
if hasattr(path, "__fspath__"):
if isinstance(path, getattr(os, "PathLike", ())):
path = os.fspath(path)
elif hasattr(path, "__fspath__"):
path = path.__fspath__()
if path.__class__.__module__ == "pathlib":
elif path.__class__.__module__ == "pathlib":
import pathlib
if isinstance(path, pathlib.Path):
path = str(path)
path = str(path)

parsed = urlparse(path)
if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0:
Expand Down
10 changes: 6 additions & 4 deletions uproot/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import itertools
import math
import numbers
import os.path
import os
import re
import struct
import sys
Expand Down Expand Up @@ -98,12 +98,14 @@ def _delayedraise(excinfo):
raise err.with_traceback(trc)

def _filename_explode(x):
if hasattr(x, "__fspath__"):
if isinstance(x, getattr(os, "PathLike", ())):
x = os.fspath(x)
elif hasattr(x, "__fspath__"):
x = x.__fspath__()
if x.__class__.__module__ == "pathlib":
elif x.__class__.__module__ == "pathlib":
import pathlib
if isinstance(x, pathlib.Path):
x = str(x)
x = str(x)
parsed = urlparse(x)
if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0:
pattern = os.path.expanduser(parsed.netloc + parsed.path)
Expand Down

0 comments on commit 7ea7758

Please sign in to comment.