diff -r 0c508d87f80b Lib/ntpath.py --- a/Lib/ntpath.py Fri Dec 06 17:25:51 2013 +0200 +++ b/Lib/ntpath.py Fri Dec 06 20:57:03 2013 +0200 @@ -240,26 +240,12 @@ """ 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 diff -r 0c508d87f80b Lib/test/test_ntpath.py --- a/Lib/test/test_ntpath.py Fri Dec 06 17:25:51 2013 +0200 +++ b/Lib/test/test_ntpath.py Fri Dec 06 20:57:03 2013 +0200 @@ -67,6 +67,29 @@ tester('ntpath.splitdrive("//conky//mountpoint/foo/bar")', ('', '//conky//mountpoint/foo/bar')) + def test_splitunc(self): + with self.assertWarns(DeprecationWarning): + ntpath.splitunc('') + with support.check_warnings(('', DeprecationWarning)): + tester('ntpath.splitunc("c:\\foo\\bar")', + ('', 'c:\\foo\\bar')) + tester('ntpath.splitunc("c:/foo/bar")', + ('', 'c:/foo/bar')) + tester('ntpath.splitunc("\\\\conky\\mountpoint\\foo\\bar")', + ('\\\\conky\\mountpoint', '\\foo\\bar')) + tester('ntpath.splitunc("//conky/mountpoint/foo/bar")', + ('//conky/mountpoint', '/foo/bar')) + tester('ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")', + ('', '\\\\\\conky\\mountpoint\\foo\\bar')) + tester('ntpath.splitunc("///conky/mountpoint/foo/bar")', + ('', '///conky/mountpoint/foo/bar')) + tester('ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")', + ('', '\\\\conky\\\\mountpoint\\foo\\bar')) + tester('ntpath.splitunc("//conky//mountpoint/foo/bar")', + ('', '//conky//mountpoint/foo/bar')) + self.assertEqual(ntpath.splitunc('//conky/mountpoint\u0130/foo/bar'), + ('//conky/mountpoint\u0130', '/foo/bar')) + def test_split(self): tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar')) tester('ntpath.split("\\\\conky\\mountpoint\\foo\\bar")',