Open
Description
Bug report
Bug description:
In Windows if the CWD has a device selector \\.\
or \\?\
any function dependent on nt._getfullpathname
may change the meaning of the path.
import os
import ntpath
os.chdir('\\\\?\\C:\\') # any path with a device selector
print(ntpath.abspath('\\')) # NOTE: single slash character
That code will print \\
and I mean 2 slashes, not an escaped one.
So if you use:
print(ntpath.abspath('\\Some\\Path')) # single slash before each component
The result is \\Some\Path
.
That is an UNC network share, not a file named Path
a couple of levels down from the root of the volume.
Perhaps there are security concerns there.
And if the CWD is a volume root, or drive device root, then:
os.chdir('\\\\.\\C:\\') # or \\?\Volume{GUID}\
print(ntpath.abspath('.')) # current directory
That will show \\.\C:
which is a device block, which means os.scandir
would raise an error with that path.
CPython versions tested on:
3.12
Operating systems tested on:
Windows