Skip to content
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify patch slightly
  • Loading branch information
barneygale committed Mar 6, 2023
commit eb7087f7a9f44823071559ba363c8cd0579a1981
14 changes: 5 additions & 9 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ def __reduce__(self):
return (self.__class__, self.parts)

@classmethod
def _join_parts(cls, parts):
def _from_parts(cls, parts):
if not parts:
return ''
path = ''
elif len(parts) == 1:
path = os.fspath(parts[0])
else:
Expand All @@ -287,7 +287,9 @@ def _join_parts(cls, parts):
"argument should be a str or an os.PathLike "
"object where __fspath__ returns a str, "
f"not {type(path).__name__!r}")
return path
self = object.__new__(cls)
self._fspath = path
return self

@classmethod
def _parse_path(cls, path):
Expand All @@ -305,12 +307,6 @@ def _parse_path(cls, path):
parsed = [sys.intern(x) for x in unfiltered_parsed if x and x != '.']
return drv, root, parsed

@classmethod
def _from_parts(cls, args):
self = object.__new__(cls)
self._fspath = cls._join_parts(args)
return self

def _load_parts(self):
drv, root, parts = self._parse_path(self._fspath)
self._drv = drv
Expand Down