This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Simplify string decoding in xmlrpc.client.
Type: behavior Stage: resolved
Components: Versions: Python 3.2
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: alexandre.vassalotti, loewis
Priority: normal Keywords: patch

Created on 2009-06-29 00:10 by alexandre.vassalotti, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
simplify_xmlrpc_string_decoding.diff alexandre.vassalotti, 2009-06-29 00:10
Messages (5)
msg89801 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-06-29 00:10
The following patch tries to improve how xmlrpc.client handles strings.
In particular, it simplifies the decoding of strings by keeping them as
unicode str.
msg89809 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-06-29 05:35
Did you try these changes? Can you provide a test case?
msg89814 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-06-29 06:27
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@helios:py3k$ python2.6 ./xmlserve.py > /dev/null &
alex@helios:py3k$ ./python ./xmlclient.py 
["<type 'str'>", "'Bonjour'"]
["<type 'unicode'>", "u'Je suis \\xe0 Montr\\xe9al'"]
[56836 refs]
alex@helios:py3k$ patch -p0 < simplify_xmlrpc_string_decoding.diff 
patching file Lib/xmlrpc/client.py
alex@helios:py3k$ ./python ./xmlclient.py 
["<type 'str'>", "'Bonjour'"]
["<type 'unicode'>", "u'Je suis \\xe0 Montr\\xe9al'"]
[56877 refs]
msg89815 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-06-29 06:30
Oops, I forgot to update my client in my last message. The sample trace
run should make more sense now.

#!/usr/bin/python3.2
# xmlclient.py
import xmlrpc.client
server_proxy = xmlrpc.client.ServerProxy("http://localhost:8000")
print(server_proxy.print_str("Bonjour"))
print(server_proxy.print_str("Je suis à Montréal"))
msg90792 - (view) Author: Alexandre Vassalotti (alexandre.vassalotti) * (Python committer) Date: 2009-07-22 02:32
Patch committed in r74156 (branches/py3k).
History
Date User Action Args
2022-04-11 14:56:50adminsetgithub: 50609
2009-07-22 02:32:59alexandre.vassalottisetstatus: open -> closed
resolution: accepted
messages: + msg90792

stage: patch review -> resolved
2009-06-29 06:30:05alexandre.vassalottisetmessages: + msg89815
2009-06-29 06:27:09alexandre.vassalottisetmessages: + msg89814
2009-06-29 05:35:40loewissetnosy: + loewis
messages: + msg89809
2009-06-29 00:10:37alexandre.vassalotticreate