From 89d959b6bb2fc21a70cc6646d1c7301dd31e64d2 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Mon, 8 Apr 2024 22:03:30 +0200 Subject: [PATCH] Workaround for a quite strange UnicodeDecodeError Not really understood, but with level MSG_TRACE2, on a Curiosity Nano board, I get two instances of unicode decode errors within the trace messages. Trying to debug them did not yield any useful result, but catching the exception, and enforcing the type to be "str" appear to be able to continue. Maybe an internal bug of my Python interpreter, don't know. --- src/python/adgui.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/python/adgui.py b/src/python/adgui.py index 5259cadd..e5cb49ba 100755 --- a/src/python/adgui.py +++ b/src/python/adgui.py @@ -655,7 +655,11 @@ class adgui(QObject): if backslash_v and not self.at_bol[target]: s += "\n" s += msg - self.at_bol[target] = s[-1] == '\n' + try: + self.at_bol[target] = s[-1] == '\n' + except UnicodeDecodeError: + s = str(s) + self.at_bol[target] = s[-1] == '\n' self.log(s, msglvl, no_nl = True) def progress_callback(self, percent: int, etime: float, hdr: str, finish: int):