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:
parent
812ddaa1b0
commit
9732b48788
1 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue