Fix a regression that broke msgfmt for non-ascii strings in 3.45 on python2

This commit is contained in:
Kovid Goyal 2019-07-17 18:22:36 +05:30
parent 78f1896c69
commit 449240222b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -112,6 +112,7 @@ def make(filename, outfile):
ID = 1 ID = 1
STR = 2 STR = 2
CTXT = 3 CTXT = 3
unicode_prefix = 'u' if sys.version_info.major < 3 else ''
# Compute .mo name from .po name and arguments # Compute .mo name from .po name and arguments
if filename.endswith('.po'): if filename.endswith('.po'):
@ -202,10 +203,8 @@ def make(filename, outfile):
l = l.strip() l = l.strip()
if not l: if not l:
continue continue
l = ast.literal_eval(l) l = ast.literal_eval(unicode_prefix + l)
lb = l lb = l.encode(encoding)
if not isinstance(lb, bytes):
lb = lb.encode(encoding)
if section == CTXT: if section == CTXT:
msgctxt += lb msgctxt += lb
elif section == ID: elif section == ID: