Quellcode durchsuchen

weird reencoding to fix encoding problems on windows with python3

prozessorkern vor 4 Jahren
Ursprung
Commit
b6c9e38eb6
2 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  1. 7 1
      metrixpp/ext/std/tools/collect.py
  2. 0 1
      metrixpp/tests/common.py

+ 7 - 1
metrixpp/ext/std/tools/collect.py

@@ -144,9 +144,15 @@ class DirectoryReader():
                         f = open(full_path, 'rU');
                         text = f.read();
                         # getting along with the different string handling of python 2 and 3
+                        # trying to get along with different encodings to get the tests running
+                        # on windows and linux
+                        try:
+                            text = text.encode(f.encoding)
+                        except:
+                            pass
                         try:
                             text = text.decode('utf-8')
-                        except (UnicodeDecodeError, AttributeError):
+                        except:
                             pass
                         f.close()
                         checksum = binascii.crc32(text.encode('utf8')) & 0xffffffff # to match python 3

+ 0 - 1
metrixpp/tests/common.py

@@ -159,7 +159,6 @@ class ToolRunner(object):
             f = open(diff_file, 'w')
             f.write(diff_text)
             f.close()
-            print(diff_text)
         else:
             if os.path.exists(real_file):
                 os.unlink(real_file)