ext/rest.py
changeset 10708 d5e3fffa9c07
parent 10603 65ad6980976e
child 10960 9e64fddebc89
--- 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)