From b64926814b0914300f20c08f2263a06a8fa6b02f Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 20 Mar 2016 12:56:33 +0100 Subject: [PATCH] Add another fallback to log emitting in case of unicode-related error. --- src/log.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/log.py b/src/log.py index 2b0e4a7e9..0044f376e 100644 --- a/src/log.py +++ b/src/log.py @@ -133,7 +133,10 @@ class BetterFileHandler(logging.FileHandler): try: self.stream.write(msg.encode("utf8")) except (UnicodeError, TypeError): - self.stream.write(msg.encode("utf8").decode('ascii', 'replace')) + try: + self.stream.write(msg.encode("utf8").decode('ascii', 'replace')) + except (UnicodeError, TypeError): + self.stream.write(repr(msg)) self.stream.write(os.linesep) try: self.flush()