From 449240222b3dbdba8292846f7645159d86c59bd1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 17 Jul 2019 18:22:36 +0530 Subject: [PATCH] Fix a regression that broke msgfmt for non-ascii strings in 3.45 on python2 --- src/calibre/translations/msgfmt.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/calibre/translations/msgfmt.py b/src/calibre/translations/msgfmt.py index a5a2c83019..3c737b0c20 100644 --- a/src/calibre/translations/msgfmt.py +++ b/src/calibre/translations/msgfmt.py @@ -112,6 +112,7 @@ def make(filename, outfile): ID = 1 STR = 2 CTXT = 3 + unicode_prefix = 'u' if sys.version_info.major < 3 else '' # Compute .mo name from .po name and arguments if filename.endswith('.po'): @@ -202,10 +203,8 @@ def make(filename, outfile): l = l.strip() if not l: continue - l = ast.literal_eval(l) - lb = l - if not isinstance(lb, bytes): - lb = lb.encode(encoding) + l = ast.literal_eval(unicode_prefix + l) + lb = l.encode(encoding) if section == CTXT: msgctxt += lb elif section == ID: