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

> I've got a fairly simple implementation for this using the (new) 
> nt._path_splitroot native method

It's for the best to let the system path API handle this, especially if doing 
so gets this issue resolved, as well as others like it and those that depend on 
it. I'm a bit disappointed, however, that PathCchSkipRoot() doesn't handle some 
of the cases that I handled in splitdrive.py. 

PathCchSkipRoot() doesn't support the "Global" link in device paths. 
Fortunately this case is uncommon. In practice "Global" is only needed when a 
DOS device name has to be created globally, e.g. "\\.\Global\SomeGlobalDevice".

PathCchSkipRoot() splits "\\.\UNC\server\share" as "\\.\UNC\" and 
"server\share", but that's okay since no one uses "\\.\UNC". 

PathCchSkipRoot() restricts the "\\?\" prefix to drive names, volume GUID 
names, and the "UNC" device -- such as "\\?\X:", 
"\\?\Volume{12345678-1234-1234-1234-123456789ABC}", and "\\?\UNC\server\share". 
Other device names such as the "PIPE" device have to use the "\\.\" prefix. 
Rarely, a device path may need "\\?\" if it's a long path or needs to bypass 
normalization. I wanted splitdrive() to remain neutral for such cases, but that 
will have to be sacrificed.

PathCchSkipRoot() doesn't ignore repeated slashes in the drive part of a UNC 
"\\server\share" or "\\?\UNC\server\share" path, even though GetFullPathNameW() 
collapses all but the initial two slashes. (More than two initial slashes is 
invalid.) For example, the system normalizes "//localhost///C$" as 
"\\localhost\C$:

    >>> os.chdir('//localhost///C$/Temp')
    >>> print(os.getcwd())
    \\localhost\C$\Temp

PathCchSkipRoot() also allows just a UNC server to count as a root, e.g. 
"\\server" or "\\?\UNC\server", though a valid UNC path requires a share name. 
Without a share, FindFirstFileW(L"//server/*", &find_data) will fail to parse 
the directory name correctly and try to open "//server/*", which is an invalid 
name. If splitdrive() requires a valid drive name, it should not return 
"//server" or "//server/" as a drive name.

----------

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

Reply via email to