summaryrefslogtreecommitdiff
path: root/Lib/ntpath.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2013-12-16 15:14:19 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2013-12-16 15:14:19 +0200
commitcc83b0c8f6089d67e998b4322000c1805f4cb06e (patch)
tree681cb34e68fc5ff71d78610771c445b955966e25 /Lib/ntpath.py
parentf5ad91c392199fe8fabeed34d1dce6f8be3a0921 (diff)
parent593568bf47600154b760edf21f22090ff60a2a74 (diff)
downloadcpython-git-cc83b0c8f6089d67e998b4322000c1805f4cb06e.tar.gz
Issue #19912: Fixed numerous bugs in ntpath.splitunc().
* splitunc() no more return illegal result for paths with redundant slashes. * splitunc() now correctly processes the 'İ' character (U+0130, LATIN CAPITAL LETTER I WITH DOT ABOVE). * Deprecation warnings now emitted for every use of splitunc(). * Added tests for splitunc().
Diffstat (limited to 'Lib/ntpath.py')
-rw-r--r--Lib/ntpath.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py
index 3d9e2009d8..dd64962e8b 100644
--- a/Lib/ntpath.py
+++ b/Lib/ntpath.py
@@ -240,26 +240,12 @@ def splitunc(p):
"""
import warnings
warnings.warn("ntpath.splitunc is deprecated, use ntpath.splitdrive instead",
- DeprecationWarning)
- sep = _get_sep(p)
- if not p[1:2]:
- return p[:0], p # Drive letter present
- firstTwo = p[0:2]
- if normcase(firstTwo) == sep + sep:
- # is a UNC path:
- # vvvvvvvvvvvvvvvvvvvv equivalent to drive letter
- # \\machine\mountpoint\directories...
- # directory ^^^^^^^^^^^^^^^
- normp = normcase(p)
- index = normp.find(sep, 2)
- if index == -1:
- ##raise RuntimeError, 'illegal UNC path: "' + p + '"'
- return (p[:0], p)
- index = normp.find(sep, index + 1)
- if index == -1:
- index = len(p)
- return p[:index], p[index:]
- return p[:0], p
+ DeprecationWarning, 2)
+ drive, path = splitdrive(p)
+ if len(drive) == 2:
+ # Drive letter present
+ return p[:0], p
+ return drive, path
# Split a path in head (everything up to the last '/') and tail (the