On 2019-07-13, Jürgen Spitzmüller wrote: > [-- Type: text/plain, Encoding: quoted-printable --]
> make_i18n.inc (in po/) fails for me with this error: > /usr/bin/python3 ./postats.py "2.4.0dev" ar.po bg.po cs.po de.po el.po > en.po es.po eu.po fi.po fr.po he.po hu.po ia.po id.po it.po ja.po nb.po > nl.po nn.po pl.po pt_BR.po pt_PT.po ru.po sk.po sv.po tr.po uk.po > zh_CN.po zh_TW.po >i18n.inc > Traceback (most recent call last): > File "./postats.py", line 144, in <module> > )?>""" % (sys.argv[1], branch_tag, ",".join([run_msgfmt(po) for po > in sys.argv[2:] if po not in ommitted]))) > File "./postats.py", line 144, in <listcomp> > )?>""" % (sys.argv[1], branch_tag, ",".join([run_msgfmt(po) for po > in sys.argv[2:] if po not in ommitted]))) > File "./postats.py", line 103, in run_msgfmt > header = read_pofile(pofile) > File "./postats.py", line 72, in read_pofile > for line in open(pofile): > File "/usr/lib64/python3.7/encodings/ascii.py", line 26, in decode > return codecs.ascii_decode(input, self.errors)[0] > UnicodeDecodeError: 'ascii' codec can't decode byte 0xd8 in position > 872: ordinal not in range(128) > make: *** [Makefile:820: i18n.inc] Error 1 > Pythonists, any idea? This file is for Python2. The patch below made it work with Python3.5 here. Günter diff --git a/po/postats.py b/po/postats.py index 8c5f058642..392c830683 100755 --- a/po/postats.py +++ b/po/postats.py @@ -37,6 +37,7 @@ ommitted = ('en.po') import os import sys +from subprocess import Popen, PIPE # Reset the locale import locale @@ -69,7 +70,7 @@ def read_pofile(pofile): """ Read the header of the pofile and return it as a dictionary""" header = {} read_header = False - for line in open(pofile): + for line in open(pofile, encoding='utf8'): line = line[:-1] if line[:5] == 'msgid': if read_header: @@ -112,12 +113,13 @@ def run_msgfmt(pofile): prop["email"] = prop["email"].replace(".", " ! ") translator = header['Last-Translator'].split('<')[0].strip() try: - prop["translator"] = translator.decode(charset).encode('ascii','xmlcharrefreplace') + prop["translator"] = translator.encode('ascii','xmlcharrefreplace') except LookupError: prop["translator"] = translator - p_in, p_out = os.popen4("msgfmt --statistics -o %s %s" % (gmofile, pofile)) - extract_number(p_out.readline(), + P = Popen("msgfmt --statistics -o %s %s" % (gmofile, pofile), + shell=True, stdin=PIPE, stdout=PIPE, close_fds=True) + extract_number(P.stdout.readline().decode(), ('translated', 'fuzzy', 'untranslated'), prop) return """