summaryrefslogtreecommitdiffstats
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 1cec895..6aa1e85 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -70,6 +70,12 @@ def _get_colon(path):
else:
return ':'
+def _get_special(path):
+ if isinstance(path, bytes):
+ return (b'\\\\.\\', b'\\\\?\\')
+ else:
+ return ('\\\\.\\', '\\\\?\\')
+
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
# (this is done by normpath).
@@ -508,6 +514,13 @@ def normpath(path):
"""Normalize path, eliminating double slashes, etc."""
sep = _get_sep(path)
dotdot = _get_dot(path) * 2
+ special_prefixes = _get_special(path)
+ if path.startswith(special_prefixes):
+ # in the case of paths with these prefixes:
+ # \\.\ -> device names
+ # \\?\ -> literal paths
+ # do not do any normalization, but return the path unchanged
+ return path
path = path.replace(_get_altsep(path), sep)
prefix, path = splitdrive(path)