Skip to content

Commit

Permalink
Be more robust to unicode decode errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonGross committed Nov 6, 2024
1 parent 72d12ad commit ac37d3d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion gbmi/utils/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def forward_output(
buffer = ""
prev_newline = False
for char in iter(lambda: stream.read(1), b""):
decoded_char = char.decode()
try:
decoded_char = char.decode()
except UnicodeDecodeError:
decoded_char = repr(char)
cur_newline = decoded_char == "\n"
if suppress_repeated_newlines and prev_newline and cur_newline:
continue
Expand Down

0 comments on commit ac37d3d

Please sign in to comment.