From: Georg Brandl Date: Fri, 13 Feb 2009 10:50:01 +0000 (+0000) Subject: part of #3613: fix get_host_info() usage of base64.encodestring(). X-Git-Tag: v3.1a1~189 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8dcfb6cece2da41d7b86879af1f4b81f98d70df;p=python part of #3613: fix get_host_info() usage of base64.encodestring(). --- diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py index 7c68e4cc6e..d1ed40fa29 100644 --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -135,6 +135,14 @@ class XMLRPCTestCase(unittest.TestCase): 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@host.tld"), + ('host.tld', + [('Authorization', 'Basic dXNlcg==')], {})) + + class HelperTestCase(unittest.TestCase): def test_escape(self): self.assertEqual(xmlrpclib.escape("a&b"), "a&b") diff --git a/Lib/xmlrpc/client.py b/Lib/xmlrpc/client.py index e66ee843a1..86988deefa 100644 --- a/Lib/xmlrpc/client.py +++ b/Lib/xmlrpc/client.py @@ -1161,7 +1161,8 @@ class Transport: 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)