Eryk Sun <eryk...@gmail.com> added the comment:
> _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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue46287> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com