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:
Barney Gale 2023-02-17 14:08:14 +00:00 committed by GitHub
parent d401b20630
commit 072011b3c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 1 deletions

View file

@ -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):
"""