Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions Lib/pathlib/_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,12 @@ class PurePathBase:
parser = ParserBase()
_globber = PathGlobber

def __init__(self, arg, *args):
paths = [arg]
paths.extend(args)
for path in paths:
if not isinstance(path, str):
def __init__(self, *args):
for arg in args:
if not isinstance(arg, str):
raise TypeError(
f"path should be a str, not {type(path).__name__!r}")
self._raw_paths = paths
f"argument should be a str, not {type(arg).__name__!r}")
self._raw_paths = list(args)
self._resolving = False

def with_segments(self, *pathsegments):
Expand Down Expand Up @@ -270,7 +268,7 @@ def relative_to(self, other, *, walk_up=False):
raise ValueError(f"'..' segment in {str(other)!r} cannot be walked")
else:
parts0.append('..')
return self.with_segments('', *reversed(parts0))
return self.with_segments(*reversed(parts0))

def is_relative_to(self, other):
"""Return True if the path is relative to another path or False.
Expand Down Expand Up @@ -746,7 +744,7 @@ def cwd(cls):
# enable users to replace the implementation of 'absolute()' in a
# subclass and benefit from the new behaviour here. This works because
# os.path.abspath('.') == os.getcwd().
return cls('').absolute()
return cls().absolute()

def expanduser(self):
""" Return a new path with expanded ~ and ~user constructs
Expand Down
1 change: 1 addition & 0 deletions Lib/test/test_pathlib/test_pathlib_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def test_constructor_common(self):
P = self.cls
p = P('a')
self.assertIsInstance(p, P)
P()
P('a', 'b', 'c')
P('/a', 'b', 'c')
P('a/b/c')
Expand Down
Loading