diff --git a/uproot/rootio.py b/uproot/rootio.py index b912edeb..0bbe0089 100644 --- a/uproot/rootio.py +++ b/uproot/rootio.py @@ -54,6 +54,11 @@ ################################################################ high-level interface def open(path, localsource=MemmapSource.defaults, xrootdsource=XRootDSource.defaults, httpsource=HTTPSource.defaults, **options): + 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..d172d290 100644 --- a/uproot/tree.py +++ b/uproot/tree.py @@ -99,6 +99,10 @@ def _delayedraise(excinfo): raise err.with_traceback(trc) def _filename_explode(x): + 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)