1 when writing an external plugin using `proxy.py`, the getstate and setstate
2 functions don't accept unicode data:
4 uncaught exception: 'ascii' codec can't encode character u'\xe4' in position 25: ordinal not in range(128)
5 Traceback (most recent call last):
6 File "proxy.py", line 309, in run
7 self._in_fd, self._out_fd)
8 File "proxy.py", line 192, in handle_rpc
9 ret = self._dispatcher.dispatch(method, params)
10 File "proxy.py", line 84, in dispatch
11 return self._dispatch(method, params)
12 File "/usr/lib/python2.7/SimpleXMLRPCServer.py", line 420, in _dispatch
14 File "proxy.py", line 251, in hook_proxy
15 ret = function(self, *args)
16 File "/home/chrysn/git/ikiwiki-plugins//plugins/my_plugin", line 49, in data2html
17 proxy.setstate(kwargs['page'], 'meta', 'title', unicode_containing_umlauts)
18 File "proxy.py", line 291, in setstate
19 return self.rpc('setstate', page, id, key, value)
20 File "proxy.py", line 233, in rpc
22 File "proxy.py", line 178, in send_rpc
24 UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 25: ordinal not in range(128)
26 the culprit is the last `_debug_fn` invocation in `send_rpc` (line 178), where
27 unicode data is format-fed into a string. while this could be circumvented by
28 making the formatting string a unicode string, that would cause trouble with
29 python3 and we'd just move the problem to the stderr writing later on; instead,
30 "`cmd, data))`" should become "`cmd, repr(data)))`" and everything is fine.
31 debug output doesn't look that pretty any more, but is safe.
35 > ok, [[done]] --[[Joey]]