diff --git a/Lib/pathlib/__init__.py b/Lib/pathlib/__init__.py index f4668ab3270e51..4f2dfd908cfe35 100644 --- a/Lib/pathlib/__init__.py +++ b/Lib/pathlib/__init__.py @@ -70,7 +70,7 @@ def __new__(cls, *args, **kwargs): cls = PureWindowsPath if os.name == 'nt' else PurePosixPath return object.__new__(cls) - def __init__(self, *args): + def _load_args(self, args): paths = [] for arg in args: if isinstance(arg, PurePath): @@ -90,7 +90,7 @@ def __init__(self, *args): "object where __fspath__ returns a str, " f"not {type(path).__name__!r}") paths.append(path) - super().__init__(*paths) + return paths def __reduce__(self): # Using the parts tuple helps share interned path parts diff --git a/Lib/pathlib/_abc.py b/Lib/pathlib/_abc.py index 4808d0e61f7038..160840497f4065 100644 --- a/Lib/pathlib/_abc.py +++ b/Lib/pathlib/_abc.py @@ -206,10 +206,14 @@ class PurePathBase: ) pathmod = os.path - def __init__(self, *paths): - self._raw_paths = paths + def __init__(self, *args): + self._raw_paths = self._load_args(args) self._resolving = False + def _load_args(self, args): + # overridden in pathlib.PurePath + return args + def with_segments(self, *pathsegments): """Construct a new path object from any number of path-like objects. Subclasses may override this method to customize how new path objects