Amend the collapsing the leading slashes to account for the POSIX special case of two leading slashes.

Thanks to Daniel Colascione for noticing.
This commit is contained in:
Antoine Pitrou 2012-12-29 01:46:48 +01:00
parent 2e8f456d88
commit 3b72e78196
1 changed files with 13 additions and 3 deletions

View File

@ -292,19 +292,29 @@ Extraneous path separators and ``"."`` components are eliminated, but not
PurePosixPath('a/../b')
Multiple leading slashes are treated differently depending on the path
flavour::
flavour. They are always retained on Windows paths (because of the UNC
notation)::
>>> PurePosixPath('//some/path')
PurePosixPath('/some/path')
>>> PureNTPath('//some/path')
PureNTPath('\\\\some\\path\\')
On POSIX, they are collapsed except if there are exactly two leading slashes,
which is a special case in the POSIX specification on `pathname resolution`_
(this is also necessary for Cygwin compatibility)::
>>> PurePosixPath('///some/path')
PurePosixPath('/some/path')
>>> PurePosixPath('//some/path')
PurePosixPath('//some/path')
Calling the constructor without any argument creates a path object pointing
to the logical "current directory"::
>>> PurePosixPath()
PurePosixPath('.')
.. _pathname resolution: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap04.html#tag_04_11
Representing
------------