Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.3k
Closed
Description
Windows has one current directoryper 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 inntpath.abspath() by calling NT'sGetFullPathNameW() function. But in pathlib we simply prependos.getcwd(), leading to incorrect results:
>>>importos,nt,pathlib>>>os.chdir('Z:/build')>>>os.chdir('C:/')>>>os.path.abspath('Z:')'Z:\\build'>>>nt._getfullpathname('Z:')'Z:\\build'>>>pathlib.Path('Z:').absolute()WindowsPath('Z:')
This bug is present in all versions of CPython pathlib. We can't fix it by callingabspath() because it will also normalize the path, eliding '..' parts.