diff --git a/pygmt/clib/session.py b/pygmt/clib/session.py index 829381d339d..a0c11373d68 100644 --- a/pygmt/clib/session.py +++ b/pygmt/clib/session.py @@ -379,10 +379,14 @@ def print_func(file_pointer, message): # noqa: ARG001 We'll capture the messages and print them to stderr so that they will show up on the Jupyter notebook. """ - message = message.decode().strip() + # Have to use try..except due to upstream GMT bug in GMT <= 6.5.0. + # See https://github.com/GenericMappingTools/pygmt/issues/3205. + try: + message = message.decode().strip() + except UnicodeDecodeError: + return 0 self._error_log.append(message) - # flush to make sure the messages are printed even if we have a - # crash. + # Flush to make sure the messages are printed even if we have a crash. print(message, file=sys.stderr, flush=True) # noqa: T201 return 0