[Python-checkins] r72351 - in python/branches/py3k/Lib: nturl2path.py test/test_urllib.py urllib/request.py
senthil.kumaran
python-checkins at python.org
Tue May 5 20:41:13 CEST 2009
Author: senthil.kumaran
Date: Tue May 5 20:41:13 2009
New Revision: 72351
Log:
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.
Modified:
python/branches/py3k/Lib/nturl2path.py
python/branches/py3k/Lib/test/test_urllib.py
python/branches/py3k/Lib/urllib/request.py
Modified: python/branches/py3k/Lib/nturl2path.py
==============================================================================
--- python/branches/py3k/Lib/nturl2path.py (original)
+++ python/branches/py3k/Lib/nturl2path.py Tue May 5 20:41:13 2009
@@ -56,7 +56,7 @@
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)
Modified: python/branches/py3k/Lib/test/test_urllib.py
==============================================================================
--- python/branches/py3k/Lib/test/test_urllib.py (original)
+++ python/branches/py3k/Lib/test/test_urllib.py Tue May 5 20:41:13 2009
@@ -837,6 +837,18 @@
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 @@
urlencode_Tests,
Pathname_Tests,
Utility_Tests,
+ URLopener_Tests,
#FTPWrapperTests,
)
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py (original)
+++ python/branches/py3k/Lib/urllib/request.py Tue May 5 20:41:13 2009
@@ -1398,6 +1398,7 @@
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')
More information about the Python-checkins
mailing list