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 eryksun, grv87, paul.moore, steve.dower, tim.golden, zach.ware
Date 2021-10-24.11:15:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1635074113.77.0.644928530771.issue45597@roundup.psfhosted.org>
In-reply-to
Content
This is from checking whether the \\?\ prefix can be stripped. The _getfinalpathname() call that it makes fails with the initial winerror (ERROR_PATH_NOT_FOUND), since nt._getfinalpathname() still lacks support for volume GUID paths. In this case, it assumes the path doesn't exist and removes the prefix. 

This check should be skipped for all prefixed paths if they aren't drives or UNC shares. For example, if colon_sep (i.e. ":\\") is defined:

        # The path returned by _getfinalpathname will always start with \\?\ -
        # strip off that prefix unless it was already provided on the original
        # path.
        if not had_prefix and path.startswith(prefix):
            # For UNC paths, the prefix will be \\?\UNC\
            if path.startswith(unc_prefix):
                spath = new_unc_prefix + path[len(unc_prefix):]
            # For drive paths, the root is of the form \\?\X:\
            elif path.startswith(colon_sep, len(prefix) + 1):
                spath = path[len(prefix):]
            # For all others, the prefix must be retained.
            else:
                spath = None
            if spath is not None:
                # Ensure that the non-prefixed path resolves to the same path
                try:
                    if _getfinalpathname(spath) == path:
                        path = spath
                except OSError as ex:
                    # If the path does not exist and originally did not exist, then
                    # strip the prefix anyway.
                    if ex.winerror == initial_winerror:
                        path = spath
        return path
History
Date User Action Args
2021-10-24 11:15:13eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, grv87
2021-10-24 11:15:13eryksunsetmessageid: <1635074113.77.0.644928530771.issue45597@roundup.psfhosted.org>
2021-10-24 11:15:13eryksunlinkissue45597 messages
2021-10-24 11:15:13eryksuncreate