[Python-checkins] r69575 - in python/branches/py3k/Lib: test/test_xmlrpc.py xmlrpc/client.py

georg.brandl python-checkins at python.org
Fri Feb 13 11:50:01 CET 2009


Author: georg.brandl
Date: Fri Feb 13 11:50:01 2009
New Revision: 69575
Log:
part of #3613: fix get_host_info() usage of base64.encodestring().
Modified:
 python/branches/py3k/Lib/test/test_xmlrpc.py
 python/branches/py3k/Lib/xmlrpc/client.py
Modified: python/branches/py3k/Lib/test/test_xmlrpc.py
==============================================================================
--- python/branches/py3k/Lib/test/test_xmlrpc.py	(original)
+++ python/branches/py3k/Lib/test/test_xmlrpc.py	Fri Feb 13 11:50:01 2009
@@ -135,6 +135,14 @@
 xmlrpclib.loads(strg)[0][0])
 self.assertRaises(TypeError, xmlrpclib.dumps, (arg1,))
 
+ def test_get_host_info(self):
+ # see bug #3613, this raised a TypeError
+ transp = xmlrpc.client.Transport()
+ self.assertEquals(transp.get_host_info("user at host.tld"),
+ ('host.tld',
+ [('Authorization', 'Basic dXNlcg==')], {}))
+
+
 class HelperTestCase(unittest.TestCase):
 def test_escape(self):
 self.assertEqual(xmlrpclib.escape("a&b"), "a&b")
Modified: python/branches/py3k/Lib/xmlrpc/client.py
==============================================================================
--- python/branches/py3k/Lib/xmlrpc/client.py	(original)
+++ python/branches/py3k/Lib/xmlrpc/client.py	Fri Feb 13 11:50:01 2009
@@ -1161,7 +1161,8 @@
 
 if auth:
 import base64
- auth = base64.encodestring(urllib.parse.unquote(auth))
+ auth = urllib.parse.unquote_to_bytes(auth)
+ auth = base64.encodestring(auth).decode("utf-8")
 auth = "".join(auth.split()) # get rid of whitespace
 extra_headers = [
 ("Authorization", "Basic " + auth)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /