瀏覽代碼

trying to fix wrong encoding in windows python3

prozessorkern 4 年之前
父節點
當前提交
2c15b9e4be
共有 1 個文件被更改,包括 3 次插入1 次删除
  1. 3 1
      metrixpp/ext/std/tools/collect.py

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

@@ -144,8 +144,10 @@ class DirectoryReader():
                         f = open(full_path, 'rU');
                         text = f.read();
                         # getting along with the different string handling of python 2 and 3
-                        if sys.version_info[0] < 3:
+                        try:
                             text = text.decode('utf-8')
+                        except (UnicodeDecodeError, AttributeError):
+                            pass
                         f.close()
                         checksum = binascii.crc32(text.encode('utf8')) & 0xffffffff # to match python 3