Skip to content

Commit ac37d3d

Browse files
committed
Be more robust to unicode decode errors
1 parent 72d12ad commit ac37d3d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

gbmi/utils/images.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ def forward_output(
6060
buffer = ""
6161
prev_newline = False
6262
for char in iter(lambda: stream.read(1), b""):
63-
decoded_char = char.decode()
63+
try:
64+
decoded_char = char.decode()
65+
except UnicodeDecodeError:
66+
decoded_char = repr(char)
6467
cur_newline = decoded_char == "\n"
6568
if suppress_repeated_newlines and prev_newline and cur_newline:
6669
continue

0 commit comments

Comments
 (0)