classification
Title: ntpath.splitunc() is broken and not tested
Type: behavior Stage: resolved
Components: Library (Lib), Tests Versions: Python 3.4, Python 3.3, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: 19911 Superseder:
Assigned To: serhiy.storchaka Nosy List: berker.peksag, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-12-06 19:02 by serhiy.storchaka, last changed 2013-12-16 16:47 by serhiy.storchaka. This issue is now closed.

Files
File name Uploaded Description Edit
ntpath_splitunc.patch serhiy.storchaka, 2013-12-06 19:02 review
Messages (5)
msg205394 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-06 19:02
ntpath.splitunc() returns illegal results when path contains redundant slashes.

>>> import ntpath
>>> ntpath.splitunc("\\\\\\conky\\mountpoint\\foo\\bar")
('\\\\\\conky', '\\mountpoint\\foo\\bar')
>>> ntpath.splitunc("///conky/mountpoint/foo/bar")
('///conky', '/mountpoint/foo/bar')
>>> ntpath.splitunc("\\\\conky\\\\mountpoint\\foo\\bar")
('\\\\conky\\', '\\mountpoint\\foo\\bar')

It also affected by a bug from issue19911.

It also emits warnings in wrong place (from stdlib, not from places where it is used).

It has no tests.

Proposed patch fixes these issues.
msg206305 - (view) Author: Roundup Robot (python-dev) Date: 2013-12-16 13:22
New changeset 129105f8457d by Serhiy Storchaka in branch '3.3':
Issue #19912: Fixed numerous bugs in ntpath.splitunc().
http://hg.python.org/cpython/rev/129105f8457d

New changeset 5e39c69bad21 by Serhiy Storchaka in branch 'default':
Issue #19912: Fixed numerous bugs in ntpath.splitunc().
http://hg.python.org/cpython/rev/5e39c69bad21

New changeset e4beb183a674 by Serhiy Storchaka in branch '2.7':
Issue #19912: Fixed numerous bugs in ntpath.splitunc().
http://hg.python.org/cpython/rev/e4beb183a674
msg206327 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2013-12-16 16:24
Hi Serhiy, there are commented-out lines in changeset http://hg.python.org/cpython/rev/e4beb183a674. Are they intentionally there?

+    #if p[1:2] == ':':
+        #return '', p # Drive letter present
+    #firstTwo = p[0:2]
+    #if firstTwo == '//' or firstTwo == '\\\\':
+        ## is a UNC path:
+        ## vvvvvvvvvvvvvvvvvvvv equivalent to drive letter
+        ## \\machine\mountpoint\directories...
+        ##           directory ^^^^^^^^^^^^^^^
+        #normp = normcase(p)
+        #index = normp.find('\\', 2)
+        #if index == -1:
+            ###raise RuntimeError, 'illegal UNC path: "' + p + '"'
+            #return ("", p)
+        #index = normp.find('\\', index + 1)
+        #if index == -1:
+            #index = len(p)
+        #return p[:index], p[index:]
+    #return '', p
msg206328 - (view) Author: Roundup Robot (python-dev) Date: 2013-12-16 16:43
New changeset 4de09cbd3b97 by Serhiy Storchaka in branch '2.7':
Removed old implementation of ntpath.splitunc() (issue #19912).
http://hg.python.org/cpython/rev/4de09cbd3b97
msg206330 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-16 16:47
Oh, my fault. Thank you Berker.
History
Date User Action Args
2013-12-16 16:47:54serhiy.storchakasetmessages: + msg206330
2013-12-16 16:43:51python-devsetmessages: + msg206328
2013-12-16 16:24:47berker.peksagsetnosy: + berker.peksag
messages: + msg206327
2013-12-16 13:27:35serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2013-12-16 13:22:49python-devsetnosy: + python-dev
messages: + msg206305
2013-12-06 19:03:05serhiy.storchakasetdependencies: + ntpath.splitdrive() fails when UNC part contains \u0130
2013-12-06 19:02:51serhiy.storchakacreate