[Twisted-web] Confused about XML-RPC Unicode behaviour (examples attached).

kgi iacovou at gmail.com
Fri Feb 9 05:14:06 CST 2007


On Wednesday 07 February 2007 20:53, Jean-Paul Calderone wrote:

> Nope, it's probably just a bug.  It looks like it may be a bug in the
> xmlrpclib module, though.  Consider this interaction:

Thanks for your reply, JP.

You're right that it looks like a bug in xmlrpclib itself; however, it only 
looks like it's a bug in Python 2.4's version of xmlrpclib; version Python 
2.5 has a slightly different xmlrpclib.py that does not exhibit this 
behaviour; using your example:

$ python2.5
Python 2.5 (r25:51908, Oct  6 2006, 15:22:41)
[GCC 4.1.2 20060928 (prerelease) (Ubuntu 4.1.1-13ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xmlrpclib
>>> d1 = xmlrpclib.DateTime()
>>> d1
<DateTime '20070209T13:02:31' at b7d4896c>
>>> s = xmlrpclib.dumps((d1,))
>>> s
'<params>\n<param>\n<value><dateTime.iso8601>20070209T13:02:31</dateTime.iso8601></value>\n</param>\n</params>\n'
>>> d2 = xmlrpclib.loads(s)[0][0]
>>> d2
<DateTime '20070209T13:02:31' at b7d48e2c>
>>> xmlrpclib.dumps((d2,))
'<params>\n<param>\n<value><dateTime.iso8601>20070209T13:02:31</dateTime.iso8601></value>\n</param>\n</params>\n'

So obviously someone noticed that 2.4's was buggy from a round-trip 
point-of-view and corrected it for 2.5. Not sure if that means that they will 
be unreceptive to patching 2.4.

It also looks like one can just drop 2.5's xmlrpclib.py into a 2.4 tree and 
run compileall.py and the odd behaviour disappears.

Having Twisted work around this problem would be a Good Thing, however. I'll 
file a bug report.

Cheers

Ricky



More information about the Twisted-web mailing list