From b686174b07bd56af4e5ffaa23c24f27f417fc305 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 19 Feb 2023 16:05:52 +0100 Subject: Merging upstream version 2.1.1 (Closes: #1026291). Signed-off-by: Daniel Baumann --- msgfmt.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'msgfmt.py') diff --git a/msgfmt.py b/msgfmt.py index c0e093a..0d5367c 100755 --- a/msgfmt.py +++ b/msgfmt.py @@ -1,5 +1,4 @@ #!/usr/bin/env python -# -*- coding: iso-8859-1 -*- # Written by Martin v. Lwis # Plural forms support added by alexander smishlajev """ @@ -25,8 +24,6 @@ Options: --version Display version information and exit. """ -from __future__ import print_function, unicode_literals - import array import ast import getopt @@ -103,10 +100,7 @@ def generate(): 0, 0, ) # size and offset of hash table - if sys.version_info.major == 2: - output += array.array(b'i', offsets).tostring() - else: - output += array.array('i', offsets).tobytes() + output += array.array('i', offsets).tobytes() output += ids.encode('utf8') output += strs.encode('utf8') return output @@ -127,11 +121,9 @@ def make(filename, outfile): outfile = os.path.splitext(infile)[0] + '.mo' try: - import io - - with io.open(infile, encoding='utf8') as _file: + with open(infile, encoding='utf8') as _file: lines = _file.readlines() - except IOError as msg: + except OSError as msg: print(msg, file=sys.stderr) sys.exit(1) @@ -181,9 +173,6 @@ def make(filename, outfile): if not line: continue line = ast.literal_eval(line) - # Python 2 ast.literal_eval returns bytes. - if isinstance(line, bytes): - line = line.decode('utf8') if section == section_id: msgid += line elif section == section_str: @@ -202,7 +191,7 @@ def make(filename, outfile): try: with open(outfile, 'wb') as _file: _file.write(output) - except IOError as msg: + except OSError as msg: print(msg, file=sys.stderr) -- cgit v1.2.3