py_ext/PythonFileCTNMixin.py
changeset 2459 21164625b393
parent 2442 b13f021c68a5
child 2679 2783906d5792
--- a/py_ext/PythonFileCTNMixin.py	Fri Nov 23 11:01:20 2018 +0100
+++ b/py_ext/PythonFileCTNMixin.py	Fri Nov 23 12:13:24 2018 +0100
@@ -27,8 +27,9 @@
 from __future__ import absolute_import
 import os
 import re
+from builtins import str as text
+
 import util.paths as paths
-
 from xmlclass import GenerateParserFromXSD
 
 from CodeFileTreeNode import CodeFile
@@ -62,8 +63,8 @@
                 'xmlns="http://www.w3.org/2001/XMLSchema"',
                 'xmlns:xhtml="http://www.w3.org/1999/xhtml"')
             for cre, repl in [
-                    (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
-                    (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
+                    (re.compile(r"(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
+                    (re.compile(r"(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
                 pythonfile_xml = cre.sub(repl, pythonfile_xml)
 
             try:
@@ -74,7 +75,7 @@
                     self.CreateCodeFileBuffer(False)
                     self.OnCTNSave()
             except Exception as exc:
-                error = unicode(exc)
+                error = text(exc)
 
             if error is not None:
                 self.GetCTRoot().logger.write_error(
@@ -317,4 +318,4 @@
         return ([(Gen_PyCfile_path, matiec_CFLAGS)],
                 "",
                 True,
-                ("runtime_%s.py" % location_str, file(runtimefile_path, "rb")))
+                ("runtime_%s.py" % location_str, open(runtimefile_path, "rb")))