cpython (2.7): Issue #12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of

http://hg.python.org/cpython/rev/c02e790c4535 changeset: 72450:c02e790c4535 branch: 2.7 parent: 72447:93a5388a3721 user: Victor Stinner <victor.stinner@haypocalc.com> date: Fri Sep 23 01:15:32 2011 +0200 summary: Issue #12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of failing with a UnicodeDecodeError. files: Lib/test/test_xmlrpc.py | 3 +++ Lib/xmlrpclib.py | 3 +++ Misc/NEWS | 3 +++ 3 files changed, 9 insertions(+), 0 deletions(-) diff --git a/Lib/test/test_xmlrpc.py b/Lib/test/test_xmlrpc.py --- a/Lib/test/test_xmlrpc.py +++ b/Lib/test/test_xmlrpc.py @@ -472,6 +472,9 @@ # protocol error; provide additional information in test output self.fail("%s\n%s" % (e, getattr(e, "headers", ""))) + def test_unicode_host(self): + server = xmlrpclib.ServerProxy(u"http://%s:%d/RPC2"%(ADDR, PORT)) + self.assertEqual(server.add("a", u"\xe9"), u"a\xe9") # [ch] The test 404 is causing lots of false alarms. def XXXtest_404(self): diff --git a/Lib/xmlrpclib.py b/Lib/xmlrpclib.py --- a/Lib/xmlrpclib.py +++ b/Lib/xmlrpclib.py @@ -1539,6 +1539,9 @@ allow_none=0, use_datetime=0): # establish a "logical" server connection + if isinstance(uri, unicode): + uri = uri.encode('ISO-8859-1') + # get the url import urllib type, uri = urllib.splittype(uri) diff --git a/Misc/NEWS b/Misc/NEWS --- a/Misc/NEWS +++ b/Misc/NEWS @@ -47,6 +47,9 @@ Library ------- +- Issue #12931: xmlrpclib now encodes Unicode URI to ISO-8859-1, instead of + failing with a UnicodeDecodeError. + - Issue #8933: distutils' PKG-INFO files will now correctly report Metadata-Version: 1.1 instead of 1.0 if a Classifier or Download-URL field is present. -- Repository URL: http://hg.python.org/cpython
participants (1)
-
victor.stinner