[issue6360] Simplify string decoding in xmlrpc.client.

Alexandre Vassalotti report at bugs.python.org
Mon Jun 29 08:27:11 CEST 2009


Alexandre Vassalotti <alexandre at peadrop.com> added the comment:

I didn't test the changes extensively. I ran the test suite and the
changes seemed to be correct.

It is a bit difficult to provide a test case, since the patch shouldn't
change how the code currently behave. Nevertheless, here is a simple
example:

#!/usr/bin/python3.2
# xmlclient.py
import xmlrpc.client
server_proxy = xmlrpc.client.ServerProxy("http://localhost:8000")
print(server_proxy.print_str("être à montréal"))

#!/usr/bin/python2.6
# xmlserve.py
from SimpleXMLRPCServer import SimpleXMLRPCServer
def print_str(s):
  return (repr(type(s)), repr(s)) 
server = SimpleXMLRPCServer(("localhost", 8000))
server.register_function(print_str)
server.serve_forever()

And here's a sample run:

alex at helios:py3k$ python2.6 ./xmlserve.py > /dev/null &
alex at helios:py3k$ ./python ./xmlclient.py 
["<type 'str'>", "'Bonjour'"]
["<type 'unicode'>", "u'Je suis \\xe0 Montr\\xe9al'"]
[56836 refs]
alex at helios:py3k$ patch -p0 < simplify_xmlrpc_string_decoding.diff 
patching file Lib/xmlrpc/client.py
alex at helios:py3k$ ./python ./xmlclient.py 
["<type 'str'>", "'Bonjour'"]
["<type 'unicode'>", "u'Je suis \\xe0 Montr\\xe9al'"]
[56877 refs]

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6360>
_______________________________________


More information about the Python-bugs-list mailing list