[Python-checkins] r83415 - in python/branches/py3k/Lib: test/test_urllib.py urllib/request.py
senthil.kumaran
python-checkins at python.org
Sun Aug 1 19:53:38 CEST 2010
Author: senthil.kumaran
Date: Sun Aug 1 19:53:37 2010
New Revision: 83415
Log:
Fix Issue8123 - TypeError in urllib when trying to use HTTP authentication
Modified:
python/branches/py3k/Lib/test/test_urllib.py
python/branches/py3k/Lib/urllib/request.py
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 Sun Aug 1 19:53:37 2010
@@ -190,6 +190,17 @@
finally:
self.unfakehttp()
+ def test_userpass_inurl(self):
+ self.fakehttp(b"Hello!")
+ try:
+ fp = urlopen("http://user:pass@python.org/")
+ self.assertEqual(fp.readline(), b"Hello!")
+ self.assertEqual(fp.readline(), b"")
+ self.assertEqual(fp.geturl(), 'http://user:pass@python.org/')
+ self.assertEqual(fp.getcode(), 200)
+ finally:
+ self.unfakehttp()
+
class urlretrieve_FileTests(unittest.TestCase):
"""Test urllib.urlretrieve() on local files"""
Modified: python/branches/py3k/Lib/urllib/request.py
==============================================================================
--- python/branches/py3k/Lib/urllib/request.py (original)
+++ python/branches/py3k/Lib/urllib/request.py Sun Aug 1 19:53:37 2010
@@ -1591,13 +1591,13 @@
if proxy_passwd:
import base64
- proxy_auth = base64.b64encode(proxy_passwd).strip()
+ proxy_auth = base64.b64encode(proxy_passwd.encode()).strip()
else:
proxy_auth = None
if user_passwd:
import base64
- auth = base64.b64encode(user_passwd).strip()
+ auth = base64.b64encode(user_passwd.encode()).strip()
else:
auth = None
http_conn = connection_factory(host)
More information about the Python-checkins
mailing list