mirror of
https://github.com/python/cpython.git
synced 2025-07-19 01:05:26 +00:00
gh-100809: Fix handling of drive-relative paths in pathlib.Path.absolute() (GH-100812)
Resolving the drive independently uses the OS API, which ensures it starts from the current directory on that drive.
This commit is contained in:
parent
d401b20630
commit
072011b3c3
4 changed files with 64 additions and 1 deletions
|
@ -816,7 +816,12 @@ class Path(PurePath):
|
|||
"""
|
||||
if self.is_absolute():
|
||||
return self
|
||||
return self._from_parts([os.getcwd()] + self._parts)
|
||||
elif self._drv:
|
||||
# There is a CWD on each drive-letter drive.
|
||||
cwd = self._flavour.abspath(self._drv)
|
||||
else:
|
||||
cwd = os.getcwd()
|
||||
return self._from_parts([cwd] + self._parts)
|
||||
|
||||
def resolve(self, strict=False):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue