Author serhiy.storchaka
Recipients BreamoreBoy, Steven.Hartland, haypo, loewis, pitrou, serhiy.storchaka
Date 2013-05-24.16:36:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369413405.51.0.524979486676.issue7727@psf.upfronthosting.co.za>
In-reply-to
Content
Updating tests I found some related errors.

XML-RPC doesn't work in general case for non UTF-8 encoding:

>>> import xmlrpclib
>>> xmlrpclib.dumps(('\u20ac',), encoding='iso-8859-1')
'<params>\n<param>\n<value><string>\\u20ac</string></value>\n</param>\n</params>\n'
>>> xmlrpclib.dumps((u'\u20ac',), encoding='iso-8859-1')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/xmlrpclib.py", line 1085, in dumps
    data = m.dumps(params)
  File "/usr/lib/python2.7/xmlrpclib.py", line 632, in dumps
    dump(v, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 654, in __dump
    f(self, value, write)
  File "/usr/lib/python2.7/xmlrpclib.py", line 700, in dump_unicode
    value = value.encode(self.encoding)
UnicodeEncodeError: 'latin-1' codec can't encode character u'\u20ac' in position 0: ordinal not in range(256)

We should use 'xmlcharrefreplace' error handler.

Non-ASCII strings is passed as Unicode strings (this should be documented).

>>> xmlrpclib.loads(xmlrpclib.dumps(('\xe2\x82\xac',)))
((u'\u20ac',), None)

'\r' and '\r\n' are deserialized as '\n'.

>>> xmlrpclib.loads(xmlrpclib.dumps(('\r',)))
(('\n',), None)
>>> xmlrpclib.loads(xmlrpclib.dumps(('\r\n',)))
(('\n',), None)
History
Date User Action Args
2013-05-24 16:36:45serhiy.storchakasetrecipients: + serhiy.storchaka, loewis, pitrou, haypo, Steven.Hartland, BreamoreBoy
2013-05-24 16:36:45serhiy.storchakasetmessageid: <1369413405.51.0.524979486676.issue7727@psf.upfronthosting.co.za>
2013-05-24 16:36:45serhiy.storchakalinkissue7727 messages
2013-05-24 16:36:45serhiy.storchakacreate