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.
This commit is contained in:
Joerg Wunsch
2024-04-08 22:03:30 +02:00
parent 058f900ed2
commit 89d959b6bb

View File

@@ -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):