summaryrefslogtreecommitdiffstats
path: root/Lib/pathlib.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pathlib.py')
-rw-r--r--Lib/pathlib.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/pathlib.py b/Lib/pathlib.py
index 4ae1fae..f43f01e 100644
--- a/Lib/pathlib.py
+++ b/Lib/pathlib.py
@@ -322,9 +322,14 @@ class PurePath(object):
if altsep:
path = path.replace(altsep, sep)
drv, root, rel = cls._flavour.splitroot(path)
- if drv.startswith(sep):
- # pathlib assumes that UNC paths always have a root.
- root = sep
+ if not root and drv.startswith(sep) and not drv.endswith(sep):
+ drv_parts = drv.split(sep)
+ if len(drv_parts) == 4 and drv_parts[2] not in '?.':
+ # e.g. //server/share
+ root = sep
+ elif len(drv_parts) == 6:
+ # e.g. //?/unc/server/share
+ root = sep
parsed = [sys.intern(str(x)) for x in rel.split(sep) if x and x != '.']
return drv, root, parsed