diff --git a/uproot/rootio.py b/uproot/rootio.py index 25ff856e..6220ab7b 100644 --- a/uproot/rootio.py +++ b/uproot/rootio.py @@ -54,6 +54,13 @@ ################################################################ high-level interface def open(path, localsource=MemmapSource.defaults, xrootdsource=XRootDSource.defaults, httpsource=HTTPSource.defaults, **options): + if hasattr(path, "__fspath__"): + path = path.__fspath__() + if path.__class__.__module__ == "pathlib": + import pathlib + if isinstance(path, pathlib.Path): + path = str(path) + parsed = urlparse(path) if _bytesid(parsed.scheme) == b"file" or len(parsed.scheme) == 0: path = parsed.netloc + parsed.path diff --git a/uproot/tree.py b/uproot/tree.py index 2ad3b556..0fb74822 100644 --- a/uproot/tree.py +++ b/uproot/tree.py @@ -99,6 +99,12 @@ def _delayedraise(excinfo): raise err.with_traceback(trc) def _filename_explode(x): + if hasattr(x, "__fspath__"): + x = x.__fspath__() + if x.__class__.__module__ == "pathlib": + import pathlib + if isinstance(x, pathlib.Path): + 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) diff --git a/uproot/version.py b/uproot/version.py index 7727b6bc..066eafba 100644 --- a/uproot/version.py +++ b/uproot/version.py @@ -30,7 +30,7 @@ import re -__version__ = "2.9.10" +__version__ = "2.9.11" version = __version__ version_info = tuple(re.split(r"[-\.]", __version__))