]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
plugins/proxy.py: be compatible with Python 3
authorSimon McVittie <smcv@debian.org>
Thu, 4 Sep 2014 10:42:05 +0000 (11:42 +0100)
committerSimon McVittie <smcv@debian.org>
Thu, 4 Sep 2014 10:42:05 +0000 (11:42 +0100)
plugins/proxy.py

index e8782e6e450dbd8e4d44db8c4a31d05ab51d5ef0..b61eb466c8d47ef839fc24e5d0ba54be3a9b23fa 100755 (executable)
@@ -159,7 +159,8 @@ class _IkiWikiExtPluginXMLRPCHandler(object):
         xml = _xmlrpc_client.dumps(sum(kwargs.items(), args), cmd)
         self._debug_fn(
             "calling ikiwiki procedure `{0}': [{1}]".format(cmd, repr(xml)))
-        if isinstance(xml, unicode):
+        # 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
@@ -168,7 +169,7 @@ class _IkiWikiExtPluginXMLRPCHandler(object):
         self._debug_fn('reading response from ikiwiki...')
 
         response = _IkiWikiExtPluginXMLRPCHandler._read(in_fd)
-        if isinstance(response, unicode):
+        if str is bytes and not isinstance(response, str):
             xml = response.encode('utf8')
         else:
             xml = response