Skip to content

Add a test to make sure PyGMT works with paths that contain non-ASCII characters#3280

Merged
seisman merged 14 commits intomainfrom
nonascii-path
Jul 29, 2024
Merged

Add a test to make sure PyGMT works with paths that contain non-ASCII characters#3280
seisman merged 14 commits intomainfrom
nonascii-path

Conversation

@seisman
Copy link
Member

@seisman seisman commented May 29, 2024

Description of proposed changes

This PR adds a new test to check if PyGMT works on a user account that has non-ASCII characters (e.g., Chinese characters). The issue is initially reported in #3279.

It turns out GMT and PyGMT work well on Linux/macOS, but don't work on Windows. On Windows, the errors are like:

gmtset [DEBUG]: gmtlib_get_graphics_item: Fig: 29 Subplot: 2 Panel: () Inset: 0
gmt_mkdir (intermediate) error: Invalid argument
gmt_mkdir (intermediate) error: Invalid argument
pygmt-session [DEBUG]: GMT_DATA_SERVER is oceania
pygmt-session [DEBUG]: Download remote file http://oceania.generic-mapping-tools.org/gmt_data_server.txt for the first time
pygmt-session [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/gmt_data_server.txt ...
pygmt-session [DEBUG]: Failed to release lock (Error <158>: The segment is already unlocked.

)
pygmt-session [DEBUG]: Delete C:\Users\RUNNER~1\AppData\Local\Temp/gmt_data_server.txt.download
pygmt-session [DEBUG]: Load contents from (null)/gmt_data_server.txt
pygmt-session [DEBUG]: GMT_DATA_SERVER is oceania
pygmt-session [DEBUG]: Download remote file http://oceania.generic-mapping-tools.org/gmt_hash_server.txt for the first time
pygmt-session [INFORMATION]: Downloading file http://oceania.generic-mapping-tools.org/gmt_hash_server.txt ...
pygmt-session [DEBUG]: Failed to release lock (Error <158>: The segment is already unlocked.

There are two main issues:

  • gmt_mkdir reports errors "Invalid argument"
  • The file path (null)/gmt_data_server.txt is incorrect, which means GMT->session.USERDIR=NULL

It's because when gmt_mkdir fails, GMT frees GMT->session.USERDIR (https://github.com/GenericMappingTools/gmt/blob/1c8a78b0613a227f406303930ebcf7238ad3401d/src/gmt_init.c#L3826). ChatGPT told me that the mkdir function on Windows doesn't support multi-byte characters. So I guess that's the reason and the test is skipped on Windows (I may find some time debugging this in the future but not now).

@seisman seisman changed the title Add a test to make sure PyGMT works with paths that contain non-ASCII characters WIP: Add a test to make sure PyGMT works with paths that contain non-ASCII characters May 29, 2024
@seisman seisman changed the title WIP: Add a test to make sure PyGMT works with paths that contain non-ASCII characters Add a test to make sure PyGMT works with paths that contain non-ASCII characters Jul 24, 2024
@seisman seisman added the maintenance Boring but important stuff for the core devs label Jul 24, 2024
@seisman seisman added this to the 0.13.0 milestone Jul 24, 2024
@seisman seisman added the needs review This PR has higher priority and needs review. label Jul 24, 2024
@seisman seisman requested a review from a team July 28, 2024 16:03
@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. final review call This PR requires final review and approval from a second reviewer labels Jul 28, 2024
@seisman seisman merged commit 1df8f19 into main Jul 29, 2024
@seisman seisman deleted the nonascii-path branch July 29, 2024 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Boring but important stuff for the core devs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants