lib.Result.__repr__(): Fix binary stdout exception

__repr__() tries to decode binary stdout as string and fails without a backup. Fix that.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-10 12:26:01 +02:00
commit 9732b48788
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -44,7 +44,12 @@ class Result:
if self.__stdout is None:
ret = ''
else:
ret = self.stdout_str[:20]
max_len = 40
try:
ret = self.stdout_str[:max_len]
except UnicodeDecodeError:
chunk = self.__stdout[:max_len]
ret = ''.join(chr(b) if 32 <= b <= 126 else '.' for b in chunk)
if quote:
ret = f'"{ret}"'
return ret