Description

BayleShanks reported an Unicode error in the XMLRPC handler. See below.

Example

Python 2.3.4c1 (#2, May 13 2004, 21:46:36) 
[GCC 3.3.3 (Debian 20040429)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xmlrpclib import *
>>> server = ServerProxy('http://moinmoin.wikiwikiweb.de/' + "?action=xmlrpc2")
>>> server.getPage(u'Wiki\u6c99\u7bb1')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/xmlrpclib.py", line 1029, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.3/xmlrpclib.py", line 1316, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.3/xmlrpclib.py", line 1080, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.3/xmlrpclib.py", line 1219, in _parse_response
    return u.close()
  File "/usr/lib/python2.3/xmlrpclib.py", line 742, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: 'exceptions.UnicodeDecodeError: \'ascii\' codec can\'t decode byte 0xe6 in position 4: ordinal not in range(128)\n  File "/org/moin_tw/moin-1.3/MoinMoin/wikirpc.py", line 392, in process\n    response = fn(*params)\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/wikirpc.py", line 236, in xmlrpc_getPage\n    return self.xmlrpc_getPageVersion(pagename, rev=None)\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/wikirpc.py", line 249, in xmlrpc_getPageVersion\n    if not self.request.user.may.read(pagename):\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/security.py", line 52, in <lambda>\n    return lambda pagename, Page=Page, request=request, attr=attr: Page(request, pagename).getACL(request).may(request, self.name, attr)\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/Page.py", line 66, in __init__\n    self.reset()\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/Page.py", line 74, in reset\n    qpagename = wikiutil.quoteWikinameFS(page_name)\n\n  File "/org/moin_tw/moin-1.3/MoinMoin/wikiutil.py", line 191, in quoteWikinameFS\n    wikiname = wikiname.replace(u\' \', u\'_\') # " " -> "_"\n'>

Details

This wiki.

Workaround

Discussion

>>> server.getPage(u'Wiki\u6c99\u7bb1')

If that doesn't work, it is not a bug. The specification says that the pagename is utf-8 (meaning a string in utf-8 encoding).

But u'Wiki\u6c99\u7bb1' is a unicode object (meaning a sequence of unicode chars, each 16 or even 32bits in size), not a string.

But there are other bugs that show up if you use u'Wiki\u6c99\u7bb1'.encode('utf-8') what should definitely work.

Plan

I am trying to make the stuff a bit more flexible on whether it gets unicode objects or utf-8 strings. I also already changed error handler to raise a remote exception if somebody feeds iso-8859-1 instead of unicode/utf-8 (it did hang in that case before the fix).


CategoryMoinMoinBugFixed

MoinMoin: MoinMoinBugs/XmlRpcDoesNotLikeUnicode (last edited 2007-10-29 19:21:25 by localhost)