[py3k] unicode → six.text_type
authorRémi Cardona <remi.cardona@logilab.fr>
Fri, 18 Sep 2015 12:03:12 +0200
changeset 10708 d5e3fffa9c07
parent 10707 3f4f190f8e35
child 10709 3ada28a113f8
[py3k] unicode → six.text_type
ext/rest.py
--- a/ext/rest.py	Fri Sep 18 11:58:29 2015 +0200
+++ b/ext/rest.py	Fri Sep 18 12:03:12 2015 +0200
@@ -38,6 +38,7 @@
 from logging import getLogger
 from os.path import join
 
+from six import text_type
 from six.moves.urllib.parse import urlsplit
 
 from docutils import statemachine, nodes, utils, io
@@ -396,7 +397,7 @@
       the data formatted as HTML or the original data if an error occurred
     """
     req = context._cw
-    if isinstance(data, unicode):
+    if isinstance(data, text_type):
         encoding = 'unicode'
         # remove unprintable characters unauthorized in xml
         data = data.translate(ESC_UCAR_TABLE)
@@ -439,8 +440,8 @@
         return res
     except BaseException:
         LOGGER.exception('error while publishing ReST text')
-        if not isinstance(data, unicode):
-            data = unicode(data, encoding, 'replace')
+        if not isinstance(data, text_type):
+            data = text_type(data, encoding, 'replace')
         return xml_escape(req._('error while publishing ReST text')
                            + '\n\n' + data)