Skip to content

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

Closed
GenericMappingTools/gmt
#8461

Description

@seisman

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.

Activity

  1. added
    bug
    upstream
    on Apr 27, 2024
  2. added this to the 0.12.0 milestone on Apr 27, 2024
  3. seisman commented on Apr 27, 2024

    @seisman
    MemberAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugupstream

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions