Title: xmlrpclib.ServerProxy() doesn't support unicode uri
Type: Stage:
Components: Library (Lib) Versions: Python 2.7, Python 2.6
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2009-10-09 14:55 by vstinner, last changed 2010-09-10 22:36 by vstinner. This issue is now closed.

File name Uploaded Description Edit
xmlrpclib_unicode_host.patch vstinner, 2009-10-09 14:55
Messages (3)
msg93798 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-10-09 14:55
I backported xmlrpclib from Python trunk to Python 2.5 to get "connected
socket" (HTTP/1.1), which implies to backport also httplib, ssl and socket. It
works well. It's *much* faster, eg. 960 ms => 70 ms with HTTPS over a VPN.

I just have a little issue: if ServerProxy() URI is an unicode string and an
argument is an unicode string (with at least one non-ASCII character), the
request fails with:

  File ".../SVN/python-trunk/Lib/", line 784, in _send_output
    msg += message_body
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 320:
ordinal not in range(128)

Attached patch includes a test.

Can uri contains a login and/or pasword? If yes, should it be encoded to UTF-8
(instead of ASCII)?
msg93799 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-10-09 15:00
Hum, it looks that the issue is not on ServerProxy.__host, but on
ServerProxy.__handler. That's why my test uses "http://host:port/RPC2" instead
of "http://host:port". In the second case, the handler is set to the default value:
"/RPC2" which is str (and not unicode).
msg116054 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-09-10 22:36
Well, it was trivial to workaround this bug in my application (convert host to bytes using explicit host = str(host)). Python3 doesn't have this issue and Python 2.7 is released, I prefer to close this bug as wont fix.
Date User Action Args
2010-09-10 22:36:55vstinnersetresolution: fixed -> wont fix
2010-09-10 22:36:45vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg116054
2009-10-09 15:00:27vstinnersetmessages: + msg93799
2009-10-09 14:55:46vstinnercreate