This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Date 2018-06-18.22:40:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1529361630.0.0.56676864532.issue33898@psf.upfronthosting.co.za>
In-reply-to
Content
For \\?\ extended device paths, pathlib removes the trailing slash for the root directory if the device isn't UNC or a logical (A-Z) drive.

Correct:

    >>> str(Path('//?/UNC/'))
    '\\\\?\\UNC\\'

    >>> str(Path('//?/Z:/'))
    '\\\\?\\Z:\\'

Incorrect:

    >>> str(Path('//?/BootPartition/'))
    '\\\\?\\BootPartition'

    >>> str(Path('//?/Volume{}/'))
    '\\\\?\\Volume{}'

    >>> str(Path('//?/Global/Z:/'))
    '\\\\?\\Global\\Z:'

It keeps the trailing slash for some \\.\ paths, but not all.

Correct:

    >>> str(Path('//./BootPartition/'))
    '\\\\.\\BootPartition\\'

Incorrect:

    >>> str(Path('//./Global/Z:/'))
    '\\\\.\\Global\\Z:'

It adds a root directory to \\.\ device paths where none was specified. 

Incorrect:

    >>> str(Path('//./nul'))
    '\\\\.\\nul\\'

    >>> str(Path('//./PhysicalDrive0'))
    '\\\\.\\PhysicalDrive0\\'

    >>> str(Path('//./C:'))
    '\\\\.\\C:\\'

"\\\\.\\C:" refers to the volume device, whereas "\\\\.\\C:\\" is the root directory in the file system.

pathlib should parse \\?\ and \\.\ device paths the same way with respect to the drive and root. The difference in practice is only how Windows does (\\.\) or does not (\\?\) canonicalize the path. 

Additionally, pathlib fails to identify the drive correctly in these cases.

Incorrect:

    >>> Path('//?/Global/Z:/').drive
    '\\\\?\\'

    >>> Path('//?/BootPartition/Temp').drive
    '\\\\?\\'

Except for "UNC" and "Global" paths, the drive should be the first component after the local-device prefix. The "UNC" device also includes subsequent server and share components, if any. For the reserved "Global" symlink, it should look to the next component. For example, r'\\?\Global\UNC\server\share' is a drive. 

There's also the "GlobalRoot" symlink (or "Global\\GlobalRoot" to be pedantic), but that can't be handled generically.
History
Date User Action Args
2018-06-18 22:40:30eryksunsetrecipients: + eryksun, paul.moore, tim.golden, zach.ware, steve.dower
2018-06-18 22:40:30eryksunsetmessageid: <1529361630.0.0.56676864532.issue33898@psf.upfronthosting.co.za>
2018-06-18 22:40:29eryksunlinkissue33898 messages
2018-06-18 22:40:29eryksuncreate