This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients brian.curtin, eryksun, mandel, pitrou, tim.golden
Date 2019-03-16.07:20:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552720837.34.0.60718626693.issue15286@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-03-21 22:59:12eryksununlinkissue15286 messages
2019-03-16 07:20:37eryksunsetrecipients: + eryksun, pitrou, tim.golden, brian.curtin, mandel
2019-03-16 07:20:37eryksunsetmessageid: <1552720837.34.0.60718626693.issue15286@roundup.psfhosted.org>
2019-03-16 07:20:37eryksunlinkissue15286 messages
2019-03-16 07:20:37eryksuncreate