Eryk Sun <eryk...@gmail.com> added the comment:

For issue 7909, ntpath.normpath was modified to return the path unchanged if it 
begins with exactly either "\\\\.\\" or "\\\\?\\". Normalization is not 
skipped, however, if the prefix has one or more forward slashes instead of all 
backslashes. In this case, we can see that the old issue (e.g. \\.\nul -> 
\\nul) is no longer a problem. 

    >>> os.path.normpath('//./nul')
    '\\\\.\\nul'

Thus we can and should remove the check for `special_prefixes`.

Not normalizing local-device paths is inconsistent with WINAPI GetFullPathNameW 
(i.e. ntpath.abspath in Windows). Local-device paths are always normalized by 
the system when it's explicitly requested to do so. \\?\ local-device paths 
(with only backslash in the prefix) are only special cased to bypass 
normalization when creating or opening a file.

Also, it probably needs a separate issue, but ntpath.normpath should strip 
trailing spaces and dots from the final (or only) component for the sake of 
consistency with ntpath.abspath in Windows (where it calls GetFullPathNameW). 
For example:

    >>> os.path.normpath(r'//?/C:\test . . .')
    '\\\\?\\C:\\test . . .'
    >>> os.path.abspath(r'//?/C:\test . . .')
    '\\\\?\\C:\\test'

This normalization rule is common to all path types and all Windows versions. 
It should be supported for both ntpath.normpath and ntpath.abspath when called 
on a non-Windows platform. If an actual file or directory name ends with 
trailing dots and spaces, it is not a normal Windows path, and it should not be 
normalized.

----------
nosy: +eryksun
versions: +Python 3.7, Python 3.8 -Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue15286>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to