[issue40368] os.path.realpath uppercases Windows drive letter on Python 3.8

Eryk Sun report at bugs.python.org
Wed Apr 22 18:00:35 EDT 2020


Eryk Sun <eryksun at gmail.com> added the comment:

> This behavior is inconsistent with `os.path.abspath` where it always 
> returns lowercased drive letter, 

ntpath.abspath calls GetFullPathNameW, which generally preserves the input case of the device/drive component. But it doesn't always preserve drive-letter case. In particular, a drive-relative path gets resolved with the upper-case drive letter:

    >>> os.path.abspath('c:spam')
    'C:\\Temp\\spam'

That's a corner case that maybe needs to be addressed for ntpath.abspath. However, regarding ntpath.realpath, I see no reason for it to preserve the input case. To the contrary, it should always make a best effort to normalize the input path to use the real device and component names and replace 8.3 short names with long names.

> and also causes a failure in Gecko build script: 
> https://bugzilla.mozilla.org/show_bug.cgi?id=1628726

IMO, the bug there is using a case-insensitive path as a key without first case folding the string.

----------
nosy: +eryksun

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40368>
_______________________________________


More information about the Python-bugs-list mailing list