IDE: failsafe escaping for input not matching utf-8 encoding
authorEdouard Tisserant <edouard.tisserant@gmail.com>
Sun, 18 Aug 2024 23:36:56 +0200
changeset 3965 6c3469588c12
parent 3964 060ed03e3aec
child 3966 8cc6f56c3710
IDE: failsafe escaping for input not matching utf-8 encoding
CodeFileTreeNode.py
util/ProcessLogger.py
--- a/CodeFileTreeNode.py	Sun Aug 18 18:23:18 2024 +0200
+++ b/CodeFileTreeNode.py	Sun Aug 18 23:36:56 2024 +0200
@@ -107,7 +107,7 @@
 
         filepath = self.CodeFileName()
         if os.path.isfile(filepath):
-            xmlfile = open(filepath, 'r')
+            xmlfile = open(filepath, 'r', encoding='utf-8', errors='backslashreplace')
             codefile_xml = xmlfile.read()
             xmlfile.close()
 
--- a/util/ProcessLogger.py	Sun Aug 18 18:23:18 2024 +0200
+++ b/util/ProcessLogger.py	Sun Aug 18 23:36:56 2024 +0200
@@ -136,7 +136,7 @@
         if _debug and self.logger:
             self.logger.write("(DEBUG) launching:\n" + self.Command_str + "\n")
 
-        self.Proc = subprocess.Popen(self.Command, encoding="utf-8", **popenargs)
+        self.Proc = subprocess.Popen(self.Command, encoding="utf-8", errors="backslashreplace", **popenargs)
 
         self.outt = outputThread(
             self.Proc,