From 01d45191ae90a47944ebf786a0353ad0930febb1 Mon Sep 17 00:00:00 2001 From: Sei Lisa Date: Sun, 13 Jan 2019 00:25:28 +0100 Subject: [PATCH] Minor fixes in encoding handling This actually needs a complete overhaul, factorization et al. --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index a57ee46..8a98803 100755 --- a/main.py +++ b/main.py @@ -44,7 +44,7 @@ def ReportError(script, e): # When the encoding of stderr is unknown (e.g. when redirected to a file), # output will be encoded in UTF-8; otherwise the terminal's encoding will # be used. - enc = sys.stderr.encoding if sys.stderr.encoding is not None else 'utf8' + enc = sys.stderr.encoding or 'utf8' # Synchronize the UTF-8 encoded line with the output line in the # terminal's encoding. We need to compensate for the fact that the @@ -405,7 +405,7 @@ def main(argv): 'libdata=')) except getopt.GetoptError as e: Usage(argv[0]) - sys.stderr.write(u"\nError: " + str(e).decode('utf8') + u"\n") + sys.stderr.write(u"\nError: %s\n" % str(e).decode('utf8', 'replace')) return 1 outfile = '-'