From 76124eb80037200efe3c28219136bfbe6445a99a Mon Sep 17 00:00:00 2001 From: Christian Decker Date: Wed, 25 Nov 2020 12:49:45 +0100 Subject: [PATCH] pyln: Replace undecodeable symbols when tailing logs Logs may contain non-ASCII and non-UTF8 symbols, which crashes the tailer. It's better to replace them with a glyph representing undecodeable symbols instead, and handle the issue further up the call-chain. --- contrib/pyln-testing/pyln/testing/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index dde8c51e2..2b88857ce 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -208,7 +208,7 @@ class TailableProc(object): if len(line) == 0: break - line = line.decode('ASCII').rstrip() + line = line.decode('UTF-8', 'replace').rstrip() if self.log_filter(line): continue @@ -227,7 +227,7 @@ class TailableProc(object): for line in iter(self.proc.stderr.readline, ''): if len(line) == 0: break - self.err_logs.append(line.rstrip().decode('ASCII')) + self.err_logs.append(line.rstrip().decode('UTF-8', 'replace')).rstrip() self.proc.stderr.close() def is_in_log(self, regex, start=0):