[Python-3000-checkins] r58846 - in python/branches/py3k-pep3137/Lib: test/test_urllib2.py urllib2.py
christian.heimes
python-3000-checkins at python.org
Sun Nov 4 21:42:14 CET 2007
Author: christian.heimes
Date: Sun Nov 4 21:42:13 2007
New Revision: 58846
Modified:
python/branches/py3k-pep3137/Lib/test/test_urllib2.py
python/branches/py3k-pep3137/Lib/urllib2.py
Log:
Fixed bug in urllib2
str(b) == b is causing some bugs and maybe hiding some more. I'm not sure if it was a wise idea to allow it.
Modified: python/branches/py3k-pep3137/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_urllib2.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_urllib2.py Sun Nov 4 21:42:13 2007
@@ -999,7 +999,8 @@
self.assertEqual(len(http_handler.requests), 2)
self.assertFalse(http_handler.requests[0].has_header(auth_header))
userpass = bytes('%s:%s' % (user, password), "ascii")
- auth_hdr_value = 'Basic ' + str(base64.encodestring(userpass)).strip()
+ auth_hdr_value = ('Basic ' +
+ base64.encodestring(userpass).strip().decode())
self.assertEqual(http_handler.requests[1].get_header(auth_header),
auth_hdr_value)
Modified: python/branches/py3k-pep3137/Lib/urllib2.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/urllib2.py (original)
+++ python/branches/py3k-pep3137/Lib/urllib2.py Sun Nov 4 21:42:13 2007
@@ -802,7 +802,7 @@
user, pw = self.passwd.find_user_password(realm, host)
if pw is not None:
raw = "%s:%s" % (user, pw)
- auth = 'Basic %s' % str(base64.b64encode(raw)).strip()
+ auth = 'Basic %s' % base64.b64encode(raw).strip().decode()
if req.headers.get(self.auth_header, None) == auth:
return None
req.add_header(self.auth_header, auth)
More information about the Python-3000-checkins
mailing list