pathlib.Path.absolute() mishandles drive-relative Windows paths #100809
Labels
3.10
only security fixes
3.11
only security fixes
3.12
bugs and security fixes
topic-pathlib
type-bug
An unexpected behavior, bug, or error
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'sGetFullPathNameW()
function. But in pathlib we simply prependos.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.Linked PRs
The text was updated successfully, but these errors were encountered: