mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix parsing of .po files on python2
This commit is contained in:
parent
e94361e527
commit
cea9c6cb93
@ -166,7 +166,12 @@ def make(filename, outfile):
|
||||
if not msgid:
|
||||
# See whether there is an encoding declaration
|
||||
p = HeaderParser()
|
||||
charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
|
||||
if sys.version_info.major > 2:
|
||||
charset = p.parsestr(msgstr.decode(encoding)).get_content_charset()
|
||||
else:
|
||||
charset = p.parsestr(msgstr.decode(encoding).encode('ascii', 'replace')).get_content_charset()
|
||||
if isinstance(charset, bytes):
|
||||
charset = charset.decode('ascii')
|
||||
if charset:
|
||||
encoding = charset
|
||||
section = ID
|
||||
|
Loading…
x
Reference in New Issue
Block a user