aboutsummaryrefslogtreecommitdiff
path: root/doc/bugs/pythonproxy-utf8_again.mdwn
blob: b5564d6c173e95ee267b2a19782ef1ca15e8c1d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[[!template  id=gitbranch branch=chrysn/more-proxy-utf8-fail author="[[chrysn]]"]]

the recently introduced fixes for [[crashes in the python proxy even if disabled]]
caused the typical python2 implicit conversion failures ("'ascii' codec
can't...") on my debian sid system -- to fix it, i had to revert commit 154c4ea9e.

i did not dig down all the way to the xml / xmlrpc modules, but my impression
is that some module changed its behavior between stable and sid and now
generates `unicode` strings instead of `str`.

a [[patch]] to allow both versions by inspecting the types and en-/decoding on
demand should work both for anarcat's and my case. i did not test the python3
version, but i'm pretty sure it was already broken after the abovementioned
patch.

-- [[chrysn]]

> update 2014-06-29: the problem persists, but i found it is not trivial to
> reproduce. to demonstrate, use this test plugin:
>
>    #!/usr/bin/env python
>    # -*- coding: utf-8 -*-
>    
>    from proxy import IkiWikiProcedureProxy
>    
>    def preprocess(self, proxy, *args):
>        return repr(self.rpc('pagetype', 'schön'))
>    
>    proxy = IkiWikiProcedureProxy(__name__)
>    proxy.hook('preprocess', preprocess, id='testdirective')
>    proxy.run()
>
> note that when the 'schön' is stored in a variable, the exception changes --
> it seems to me that the issue is related to the way exceptions are encoded.
>
> the suggested patch still applies and solves the issue. --[[chrysn]]

>> In this patch band:
>>
>>     -        xml = _IkiWikiExtPluginXMLRPCHandler._read(in_fd).decode('utf8')
>>     +        response = _IkiWikiExtPluginXMLRPCHandler._read(in_fd)
>>     +        if isinstance(response, unicode):
>>     +            xml = response.encode('utf8')
>>
>> I think you mean `response.decode`, not `response.encode`.
>>
>> Other than that it looks good to me. I like the use of `repr` in debug
>> messages. --[[smcv]]