X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/bc94b6a76ebd07d64bac78776b7d10d6e1265a28..7f5c2cfa5a987d887f42d6db95f80f42ceb3b5ff:/plugins/proxy.py diff --git a/plugins/proxy.py b/plugins/proxy.py index d70a967a5..b61eb466c 100755 --- a/plugins/proxy.py +++ b/plugins/proxy.py @@ -158,15 +158,24 @@ class _IkiWikiExtPluginXMLRPCHandler(object): def send_rpc(self, cmd, in_fd, out_fd, *args, **kwargs): xml = _xmlrpc_client.dumps(sum(kwargs.items(), args), cmd) self._debug_fn( - "calling ikiwiki procedure `{0}': [{1}]".format(cmd, xml)) - _IkiWikiExtPluginXMLRPCHandler._write(out_fd, xml.encode('utf8')) + "calling ikiwiki procedure `{0}': [{1}]".format(cmd, repr(xml))) + # ensure that encoded is a str (bytestring in Python 2, Unicode in 3) + if str is bytes and not isinstance(xml, str): + encoded = xml.encode('utf8') + else: + encoded = xml + _IkiWikiExtPluginXMLRPCHandler._write(out_fd, encoded) self._debug_fn('reading response from ikiwiki...') - xml = _IkiWikiExtPluginXMLRPCHandler._read(in_fd).decode('utf8') + response = _IkiWikiExtPluginXMLRPCHandler._read(in_fd) + if str is bytes and not isinstance(response, str): + xml = response.encode('utf8') + else: + xml = response self._debug_fn( 'read response to procedure {0} from ikiwiki: [{1}]'.format( - cmd, xml)) + cmd, repr(xml))) if xml is None: # ikiwiki is going down self._debug_fn('ikiwiki is going down, and so are we...')