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
On windows, a relative path may have a drive specifier (there is a current working directory per drive), see python/cpython#100809 for background information from a related problem
program is:
import os.path
print (os.path.abspath('D:..'))
result is, for CPython 2.7, Jython 2.7.0, 2.7.4 and 2.7.5beta1:
The root of this is that Jython does not provide nt._getfullpathname. Therefore when we import ntpath we take the "not running on Windows" definition of abspath. I think CPython 2.7 would behave the same way on Unix, but with a bit of effort one can explore the effect on Windows.
Jython-2>python -S
Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)] on win32
>>> import nt
>>> del nt._getfullpathname
>>> import os.path
>>> os.path.abspath('d:..')
'd:..'
In the absence of nt._getfullpathname, Python relies on ntpath.join(os.getcwd(), path), which cannot determine the CWD belonging to a drive and behaves like so:
in the first case treating d:... as absolute winner, and ignoring the CWD-per-drive issue, but in the second case spotting that the drive letters match.
The version of ntpath we are using has older code than this that doesn't special case having the same drive. Changed in: python/cpython@31f5121
Activity
jeff5 commentedon Oct 27, 2026
Sounds like we broke something there in how paths are being joined.
Although the link is interesting, I don't think the problem stems from per-drive defaults, but is simpler. I recall struggling with (and giving up on) making
os.chdirwork properly in that way on Windows. This is interesting on where per-drive CWDs live according to your experience at the DOS prompt: https://stackoverflow.com/questions/53078528/how-to-get-current-working-directory-of-another-drive-in-batchjeff5 commentedon Oct 27, 2026
The root of this is that Jython does not provide
nt._getfullpathname. Therefore when we importntpathwe take the "not running on Windows" definition ofabspath. I think CPython 2.7 would behave the same way on Unix, but with a bit of effort one can explore the effect on Windows.In the absence of
nt._getfullpathname, Python relies onntpath.join(os.getcwd(), path), which cannot determine the CWD belonging to a drive and behaves like so:in the first case treating
d:...as absolute winner, and ignoring the CWD-per-drive issue, but in the second case spotting that the drive letters match.The version of ntpath we are using has older code than this that doesn't special case having the same drive. Changed in: python/cpython@31f5121