OSDN Git Service

GetTranslationsStatus.py: Fix UnicodeDecodeError with Python 3
authorTim Gerundt <tim@gerundt.de>
Tue, 30 Jan 2018 05:00:12 +0000 (06:00 +0100)
committerTim Gerundt <tim@gerundt.de>
Tue, 30 Jan 2018 05:00:12 +0000 (06:00 +0100)
Translations/GetTranslationsStatus.py

index 5d9cafa..7ed3d73 100644 (file)
@@ -356,6 +356,9 @@ class PoStatus(Status):
         self._poeditlanguage = ''
         self._translators = []
         
+        if self._charset == '': #If NO charset found...
+           return
+        
         if os.access(filepath, os.R_OK): #If PO(T) file can read...
           reMsgId = re.compile('^msgid "(.*)"$', re.IGNORECASE)
           reMsgStr = re.compile('^msgstr "(.*)"$', re.IGNORECASE)
@@ -453,7 +456,8 @@ class PoStatus(Status):
             reContentTypeCharset = re.compile('charset=([A-Z0-9\-]+)', re.IGNORECASE)
             rePoeditSourceCharset = re.compile('X-Poedit-SourceCharset: ([A-Z0-9\-]+)', re.IGNORECASE)
             
-            pofile = open(filepath, 'r')
+            pofile = open(filepath, 'r', errors='ignore')
+            
             for line in pofile: #For all lines...
                 line = line.strip()