You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pathlib.Path.absolute() mishandles drive-relative Windows paths #100809
Windows has one current directory per drive, and supports drive-relative paths like 'X:' and 'X:foo.txt'. This makes a conversion from relative to absolute paths more complicated than simply prepending a (single) current directory.
It's correctly handled in ntpath.abspath() by calling NT's GetFullPathNameW() function. But in pathlib we simply prepend os.getcwd(), leading to incorrect results:
This bug is present in all versions of CPython pathlib. We can't fix it by calling abspath() because it will also normalize the path, eliding '..' parts.
Activity
pythongh-100809: Fix handling of drive-relative paths in pathlib.Path…
Merge branch 'main' into pythongh-100809-path-absolute-nt
gh-100809: Fix handling of drive-relative paths in pathlib.Path.absol…
[3.11] pythongh-100809: Fix handling of drive-relative paths in pathl…
barneygale commentedon Feb 20, 2023
Fixed in #100812 (3.12), not backported due to interactions with other recent pathlib work.