8000 GH-101362: Omit path anchor from `pathlib.PurePath()._parts` by barneygale · Pull Request #102476 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-101362: Omit path anchor from pathlib.PurePath()._parts #102476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
Undo some changes to _format_parsed_parts()
  • Loading branch information
barneygale committed Mar 10, 2023
commit cce5d7ba5087120f742b3b213a8165fc9b8108c2
11 changes: 4 additions & 7 deletions Lib/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,14 +314,11 @@ def _from_parsed_parts(cls, drv, root, tail):

@classmethod
def _format_parsed_parts(cls, drv, root, tail):
sep = cls._flavour.sep
tail = sep.join(tail)
if drv or root:
return f'{drv}{root}{tail}'
elif cls._flavour.splitdrive(tail)[0]:
return f'.{sep}{tail}'
else:
return tail
return drv + root + cls._flavour.sep.join(tail)
elif tail and cls._flavour.splitdrive(tail[0])[0]:
tail = ['.'] + tail
return cls._flavour.sep.join(tail)

def __str__(self):
"""Return the string representation of the path, suitable for
Expand Down
0