diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2009-05-05 18:41:13 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2009-05-05 18:41:13 (GMT) |
commit | 690ce9b353bc0a86d0886470adbaa50e813de3b8 (patch) | |
tree | 190c0c6730249003e6f2dc0a0918c8da94c749b8 /Lib | |
parent | 501927d541ecf23a2915d2133f03f761c3baa5bb (diff) | |
download | cpython-690ce9b353bc0a86d0886470adbaa50e813de3b8.zip cpython-690ce9b353bc0a86d0886470adbaa50e813de3b8.tar.gz cpython-690ce9b353bc0a86d0886470adbaa50e813de3b8.tar.bz2 |
Fix for issue1153027, making Py3k changes similar to fix in issue918368.
This will address:
a) urllib/ in py3k,
b) urllib in py2x is addressed by issue918368.
c) urllib2 in py2x was already addressed in Revision 43132.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/nturl2path.py | 2 | ||||
-rw-r--r-- | Lib/test/test_urllib.py | 13 | ||||
-rw-r--r-- | Lib/urllib/request.py | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/Lib/nturl2path.py b/Lib/nturl2path.py index 1cfe827..ce9c3d3 100644 --- a/Lib/nturl2path.py +++ b/Lib/nturl2path.py @@ -56,7 +56,7 @@ def pathname2url(p): drive = urllib.parse.quote(comp[0].upper()) components = comp[1].split('\\') - path = '///' + drive + '|' + path = '///' + drive + ':' for comp in components: if comp: path = path + '/' + urllib.parse.quote(comp) diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py index d616eb1..da6bc2d 100644 --- a/Lib/test/test_urllib.py +++ b/Lib/test/test_urllib.py @@ -837,6 +837,18 @@ class Utility_Tests(unittest.TestCase): self.assertEqual(('user', 'a\vb'),urllib.parse.splitpasswd('user:a\vb')) self.assertEqual(('user', 'a:b'),urllib.parse.splitpasswd('user:a:b')) + +class URLopener_Tests(unittest.TestCase): + """Testcase to test the open method of URLopener class.""" + + def test_quoted_open(self): + class DummyURLopener(urllib.request.URLopener): + def open_spam(self, url): + return url + + self.assertEqual(DummyURLopener().open( + 'spam://example/ /'),'//example/%20/') + # Just commented them out. # Can't really tell why keep failing in windows and sparc. # Everywhere else they work ok, but on those machines, someteimes @@ -928,6 +940,7 @@ def test_main(): urlencode_Tests, Pathname_Tests, Utility_Tests, + URLopener_Tests, #FTPWrapperTests, ) diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 42e6d17..89ac22a 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -1398,6 +1398,7 @@ class URLopener: def open(self, fullurl, data=None): """Use URLopener().open(file) instead of open(file, 'r').""" fullurl = unwrap(to_bytes(fullurl)) + fullurl = quote(fullurl, safe="%/:=&?~#+!$,;'@()*[]") if self.tempcache and fullurl in self.tempcache: filename, headers = self.tempcache[fullurl] fp = open(filename, 'rb') |