Eryk Sun <eryk...@gmail.com> added the comment:

DOS device names are reserved in the final component of DOS drive-letter paths. 
"AUX" (plus an optional colon, spaces, or extension) becomes "\\.\AUX", which 
is "\??\AUX" in the NT object namespace. By default, "\??\AUX" is a link to 
"\??\COM1", which, if it exists, is typically a link to "\Device\Serial0". If 
there's no "COM1", then the kernel returns STATUS_OBJECT_NAME_NOT_FOUND, which 
the Windows API translates to ERROR_FILE_NOT_FOUND, which the C runtime 
translates to ENOENT, and finally Python raises FileNotFoundError.

Accessing a DOS device name requires using a device path (prefixed by "\\.\" or 
"\\?\", and forward slash is okay, e.g. "//./C:/Temp/aux.py") or a UNC path 
(e.g. "//localhost/C$/Temp/aux.py"). That said, if we create a file like this, 
programs that use regular drive-letter paths won't be able to access it. It's 
better to sanitize reserved DOS device names. This includes "CONIN$" and 
"CONOUT$", even though Microsoft's documentation overlooks these two.

----------
nosy: +eryksun

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue37515>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to