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

In zoneinfo._tzpath, _validate_tzfile_path() depends on os.path.normpath(). I 
think the Windows implementation of normpath() in the ntpath module should be 
extended to normalize reserved names in the final path component in the same 
manner as WinAPI GetFullPathNameW(). 

Alternatively, an isreserved() function could be added to os.path. This would 
allow _validate_tzfile_path() to raise a more informative exception for a 
reserved name.

Reserved names:

GetFullPathNameW() strips trailing spaces and dots from the final path 
component. This applies to all path types. For example:

    >>> nt._getfullpathname('\\\\?\\UNC/server/share/spam. . .')
    '\\\\?\\UNC\\server\\share\\spam'

GetFullPathNameW() reserves DOS device names in the final component of a 
relative path or drive path -- but not in a UNC path or device path. The 
following case-insensitive names are reserved:

    * NUL
    * CON
    * CONIN$
    * CONOUT$
    * AUX
    * PRN
    * COM<1-9>
    * LPT<1-9>

A reserved device name begins with one of the above base names plus an optional 
suffix. The suffix is zero or more spaces followed optionally by a "." or ":" 
and zero or more characters. The normalized result is a "\\\\.\\" device path 
for the base device name. For example: 

    >>> nt._getfullpathname('C:/Temp/con . spam')
    '\\\\.\\con'
    >>> nt._getfullpathname('C:/Temp/con : spam')
    '\\\\.\\con'

----------
components: +Windows
nosy: +eryksun, paul.moore, steve.dower, tim.golden, zach.ware

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

Reply via email to