Skip to content

Commit 8859ca3

Browse files
authored
Patch the callback print function to suppress the UnicodeDecodeError (#3367)
1 parent 53114b2 commit 8859ca3

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pygmt/clib/session.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,14 @@ def print_func(file_pointer, message): # noqa: ARG001
379379
We'll capture the messages and print them to stderr so that they will show
380380
up on the Jupyter notebook.
381381
"""
382-
message = message.decode().strip()
382+
# Have to use try..except due to upstream GMT bug in GMT <= 6.5.0.
383+
# See https://github.com/GenericMappingTools/pygmt/issues/3205.
384+
try:
385+
message = message.decode().strip()
386+
except UnicodeDecodeError:
387+
return 0
383388
self._error_log.append(message)
384-
# flush to make sure the messages are printed even if we have a
385-
# crash.
389+
# Flush to make sure the messages are printed even if we have a crash.
386390
print(message, file=sys.stderr, flush=True) # noqa: T201
387391
return 0
388392

0 commit comments

Comments
 (0)