diff options
author | Christian Heimes <christian@cheimes.de> | 2013-12-16 14:35:58 +0100 |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2013-12-16 14:35:58 +0100 |
commit | d9fbb446a2bbcb5558101bdfb961d1a6c0feb221 (patch) | |
tree | e569dd69d6428aba81310af649783d96a224ec4f | |
parent | cb3558dcc1d1b94c0b0ce3d8c10407679880ccd3 (diff) | |
parent | 8817d83050eabc613feed6018e979817dfe6fba0 (diff) | |
download | cpython-git-d9fbb446a2bbcb5558101bdfb961d1a6c0feb221.tar.gz |
merge
-rw-r--r-- | Lib/ntpath.py | 28 | ||||
-rw-r--r-- | Lib/test/test_ntpath.py | 26 | ||||
-rw-r--r-- | Makefile.pre.in | 3 | ||||
-rw-r--r-- | Misc/NEWS | 7 |
4 files changed, 42 insertions, 22 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 6b656976a4..dd64962e8b 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -204,7 +204,7 @@ def splitdrive(p): empty = _get_empty(p) if len(p) > 1: sep = _get_sep(p) - normp = normcase(p) + normp = p.replace(_get_altsep(p), sep) if (normp[0:2] == sep*2) and (normp[2:3] != sep): # is a UNC path: # vvvvvvvvvvvvvvvvvvvv drive letter or UNC path @@ -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 diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py index 0991d15b9a..2e6ba6395d 100644 --- a/Lib/test/test_ntpath.py +++ b/Lib/test/test_ntpath.py @@ -66,6 +66,32 @@ class TestNtpath(unittest.TestCase): ('', '\\\\conky\\\\mountpoint\\foo\\bar')) tester('ntpath.splitdrive("//conky//mountpoint/foo/bar")', ('', '//conky//mountpoint/foo/bar')) + # Issue #19911: UNC part containing U+0130 + self.assertEqual(ntpath.splitdrive('//conky/MOUNTPOİNT/foo/bar'), + ('//conky/MOUNTPOİNT', '/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/MOUNTPOİNT/foo/bar'), + ('//conky/MOUNTPOİNT', '/foo/bar')) def test_split(self): tester('ntpath.split("c:\\foo\\bar")', ('c:\\foo', 'bar')) diff --git a/Makefile.pre.in b/Makefile.pre.in index f843aa5cb0..009d4becb3 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -910,7 +910,8 @@ PYTHON_HEADERS= \ $(srcdir)/Include/warnings.h \ $(srcdir)/Include/weakrefobject.h \ pyconfig.h \ - $(PARSER_HEADERS) + $(PARSER_HEADERS) \ + $(AST_H) $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS) @@ -44,6 +44,11 @@ Core and Builtins Library ------- +- Issue #19912: Fixed numerous bugs in ntpath.splitunc(). + +- Issue #19911: ntpath.splitdrive() now correctly processes the 'İ' character + (U+0130, LATIN CAPITAL LETTER I WITH DOT ABOVE). + - Issue #19532: python -m compileall with no filename/directory arguments now respects the -f and -q flags instead of ignoring them. @@ -180,6 +185,8 @@ IDLE Tests ----- +- Issue #19912: Added tests for ntpath.splitunc(). + - Issue #19828: Fixed test_site when the whole suite is run with -S. - Issue #19928: Implemented a test for repr() of cell objects. |