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, neonene, paul.moore, steve.dower, tim.golden, zach.ware
Date 2022-01-08.01:39:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641605943.25.0.22009088015.issue46287@roundup.psfhosted.org>
In-reply-to
Content
> _Py_abspath/_getfullpathname does not always call GetFullPathNameW on 3.11.

Also, PathCchSkipRoot() doesn't recognize forward slash as a path separator, so _Py_isabs() is wrong in many cases compared to the same path that uses backslash as the path separator.

For example, _Py_isabs() wrongly returns false in the following cases, so GetFullPathNameW() is called, and ironically the misbehavior of _Py_isabs() leads to the correct result.

    >>> os.path.abspath('//spam//eggs. . .')
    '\\\\spam\\eggs'
    >>> os.path.abspath('C:/spam. . .')
    'C:\\spam'
    >>> os.path.abspath('C:/nul')
    '\\\\.\\nul'

_Py_isabs() returns true in the following cases, so only normpath() is called:

    >>> os.path.abspath(r'\\spam\\eggs. . .')
    '\\\\spam\\\\eggs. . .'
    >>> os.path.abspath('C:\\spam. . .')
    'C:\\spam. . .'
    >>> os.path.abspath('C:\\nul')
    'C:\\nul'

As the above shows, normpath() doesn't remove trailing dots and spaces from the last component of a path, and it doesn't special case DOS devices in the last component of a drive-letter path. The latter is still implemented for the NUL device in Windows 11 and implemented for all DOS devices in Windows 8.1 and 10 (e.g. CON, CONIN$, CONOUT$, AUX, PRN, COM<1-9>, LPT<1-9>).

I would prefer to remove the _Py_isabs() check from _Py_abspath() in Windows, unless there's a strong case for startup performance, in which case I'd prefer to revert the change to nt._getfullpathname() and only use _Py_abspath() during startup.
History
Date User Action Args
2022-01-14 16:57:46eryksununlinkissue46287 messages
2022-01-08 01:39:03eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower, neonene
2022-01-08 01:39:03eryksunsetmessageid: <1641605943.25.0.22009088015.issue46287@roundup.psfhosted.org>
2022-01-08 01:39:03eryksunlinkissue46287 messages
2022-01-08 01:39:03eryksuncreate