]> granicus.if.org Git - python/commitdiff
part of #3613: fix get_host_info() usage of base64.encodestring().
authorGeorg Brandl <georg@python.org>
Fri, 13 Feb 2009 10:50:01 +0000 (10:50 +0000)
committerGeorg Brandl <georg@python.org>
Fri, 13 Feb 2009 10:50:01 +0000 (10:50 +0000)
Lib/test/test_xmlrpc.py
Lib/xmlrpc/client.py

index 7c68e4cc6eeb2a2be0fa6bda923818b27f4c9379..d1ed40fa29e83312428d142006cc6567a539da08 100644 (file)
@@ -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&amp;b")
index e66ee843a1235d829bec9248b4079192dcbad450..86988deefaf857d261fcc93bf5d84552393fadfe 100644 (file)
@@ -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)