diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2011-04-14 05:18:55 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2011-04-14 05:18:55 (GMT) |
commit | 56f1e2d875109c9f9bef2d3c065a5218d1a9485b (patch) | |
tree | 37495413949637ac0b3f36e277adbf9528551943 | |
parent | c1f0577b54869325a15cd787ddfb79479653de15 (diff) | |
parent | 2d2ea1b431f9cf58aa8ac45052bd2e4cf2502a5c (diff) | |
download | cpython-56f1e2d875109c9f9bef2d3c065a5218d1a9485b.zip cpython-56f1e2d875109c9f9bef2d3c065a5218d1a9485b.tar.gz cpython-56f1e2d875109c9f9bef2d3c065a5218d1a9485b.tar.bz2 |
merge from 3.1
-rw-r--r-- | Lib/nturl2path.py | 5 | ||||
-rw-r--r-- | Lib/test/test_urllib.py | 18 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py index ce9c3d3..511dcec 100644 --- a/Lib/nturl2path.py +++ b/Lib/nturl2path.py @@ -27,9 +27,12 @@ def url2pathname(url): drive = comp[0][-1].upper() components = comp[1].split('/') path = drive + ':' - for comp in components: + for comp in components: if comp: path = path + '\\' + urllib.parse.unquote(comp) + # Issue #11474 - handing url such as |c/| + if path.endswith(':') and url.endswith('/'): + path += '\\' return path def pathname2url(p): diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index 275b2eb..7bb8a09 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -9,6 +9,7 @@ import io import unittest from test import support import os +import sys import tempfile def hexescape(char): @@ -1021,6 +1022,23 @@ class Pathname_Tests(unittest.TestCase): "url2pathname() failed; %s != %s" % (expect, result)) + @unittest.skipUnless(sys.platform == 'win32', + 'test specific to the urllib.url2path function.') + def test_ntpath(self): + given = ('/C:/', '///C:/', '/C|//') + expect = 'C:\\' + for url in given: + result = urllib.request.url2pathname(url) + self.assertEqual(expect, result, + 'urllib.request..url2pathname() failed; %s != %s' % + (expect, result)) + given = '///C|/path' + expect = 'C:\\path' + result = urllib.request.url2pathname(given) + self.assertEqual(expect, result, + 'urllib.request.url2pathname() failed; %s != %s' % + (expect, result)) + class Utility_Tests(unittest.TestCase): """Testcase to test the various utility functions in the urllib.""" @@ -53,6 +53,9 @@ Core and Builtins Library ------- +- Issue #11474: Fix the bug with url2pathname() handling of '/C|/' on Windows. + Patch by Santoso Wijaya. + - Issue #9233: Fix json.loads('{}') to return a dict (instead of a list), when _json is not available. |