Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GMT prints incorrect command line string if a list of arguments is passed #3205

Closed
seisman opened this issue Apr 27, 2024 · 1 comment · Fixed by GenericMappingTools/gmt#8461
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Milestone

Comments

@seisman
Copy link
Member

seisman commented Apr 27, 2024

This is an upstream GMT bug, which affect us after we refactored wrappers to pass a list of argument strings in PR #3139. To reproduce the bug, run:

>>> import pygmt
>>> pygmt.config(GMT_VERBOSE="d")
gmtset [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
>>> fig = pygmt.Figure()
pygmt-session [DEBUG]: Exit:  gmt_reload_settings
pygmt-session [DEBUG]: Enter: gmtlib_plot_C_format
pygmt-session [DEBUG]: Exit:  gmtlib_plot_C_format
pygmt-session [DEBUG]: Enter: gmtinit_get_history
pygmt-session [DEBUG]: gmtlib_get_graphics_item: Fig: 0 Subplot: 2 Panel: () Inset: 0
pygmt-session [DEBUG]: Initialize FFTW with 80 threads.
pygmt-session [DEBUG]: GMT_Create_Session initialized GMT structure
pygmt-session [DEBUG]: Shared Library # 0 (core). Path = /home/seisman/opt/miniconda/envs/pygmt/lib/libgmt.so
pygmt-session [DEBUG]: Loading GMT plugins from: /home/seisman/opt/miniconda/envs/pygmt/lib/gmt/plugins
pygmt-session [DEBUG]: Shared Library # 1 (supplements). Path = /home/seisman/opt/miniconda/envs/pygmt/lib/gmt/plugins/supplements.so
pygmt-session [DEBUG]: GMT now running in modern mode [Session ID = 127951]
Exception ignored on calling ctypes callback function: <function Session.create.<locals>.print_func at 0x7fa3da132480>
Traceback (most recent call last):
  File "/home/seisman/OSS/gmt/pygmt/pygmt/clib/session.py", line 387, in print_func
    message = message.decode().strip()
              ^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 59: invalid start byte
pygmt-session [DEBUG]: Revised options: 0540c3cbdfa249479128dd18720134da -
figure [DEBUG]: No figure file /home/seisman/.gmt/sessions/gmt_session.127951/gmt.figures - nothing to do
figure [DEBUG]: New figure: 1	0540c3cbdfa249479128dd18720134da	-

The exception is because GMT incorrectly outputs a string like below to stderr:

pygmt-session [DEBUG]: GMT_Call_Command string: gmt figure \x10l7"\xec\x7f\n

Here, the argument \x10l7"\xec\x7f\n makes no sense.

Upstream PR GenericMappingTools/gmt#8461 should fix the bug.

@seisman
Copy link
Member Author

seisman commented Apr 27, 2024

The upstream PR has been merged. I don't think we can have a workaround in PyGMT, since we definitely don't want to revert all changes in PR #3139. Fortunately, the upstream bug only affects users who care about the GMT_Call_Command string in the debugging message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Projects
None yet
1 participant