Apostrophes in filenames are incorrectly converted to octal codes
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 78/100
Piste de recherche
Commencez par lire le code de construction des arguments utilisé par build_arg_list et la discussion dans la PR #4987. Suivez la manière dont les options de nom de fichier sont échappées, puis ajoutez un test de régression montrant qu’une apostrophe reste littérale dans un chemin de fichier ; l’exemple fourni reproduit l’échec. Le travail est terminé lorsque le test réussit et que les chemins de fichier contenant des apostrophes arrivent à GMT sans modification.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Description of the problem
On Windows, sphdistance returns normally for outgrid="cell's.nc", but the file is missing. Using cells.nc produces the expected grid. I also reproduced this with grdcut. The native GMT CLI wrote cell's.nc successfully, and its grid matched the PyGMT control at all 18 points.
build_arg_list({"G": "cell's.nc"})[0] returns r"-Gcell\234s.nc". The apostrophe has been converted to a PostScript escape before the filename reaches GMT. File options need the literal path. Discussion in #4987
Minimal Complete Verifiable Example
from pathlib import Path
from tempfile import TemporaryDirectory
import pygmt
with TemporaryDirectory() as tmp:
for name in ("cells.nc", "cell's.nc"):
path = Path(tmp) / name
pygmt.sphdistance(
x=[85.5, 82.3, 85.8, 86.5],
y=[22.3, 22.6, 22.4, 23.3],
region=[82, 87, 22, 24],
spacing=1,
outgrid=path,
)
assert path.is_file(), name
Full error message
GMT writes the following diagnostic to stderr on Windows. The temporary directory is abbreviated.
sphdistance (gmtapi_export_grid): Not a supported grid format [<temp>\cell\234s.nc]
[Session pygmt-session (5)]: Error returned from GMT API: GMT_GRID_WRITE_ERROR (19)
[Session pygmt-session (5)]: Error returned from GMT API: GMT_GRID_WRITE_ERROR (19)
[Session pygmt-session (5)]: Error returned from GMT API: GMT_GRID_WRITE_ERROR (19)
The second assertion raises AssertionError: cell's.nc.
System information
Reproduced with the PyGMT v0.19.0 wheel and with main at f0c88198e6543f21bc4f7f1eca3f5359f9d9b20e. The following pygmt.show_versions() output is from v0.19.0, with local installation paths shortened.
PyGMT information:
version: v0.19.0
System information:
python: 3.12.0 (tags/v3.12.0:0fb18b0, Oct 2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
executable: <venv>/Scripts/python.exe
machine: Windows-11-10.0.26300-SP0
Dependency information:
numpy: 2.2.6
pandas: 2.3.3
xarray: 2026.9.0
packaging: 26.4
contextily: None
geopandas: None
IPython: None
pyarrow: None
rioxarray: None
gdal: 3.12.4
ghostscript: 10.07.1
GMT library information:
version: 6.8.0
padding: 2
share dir: <GMT>/share
plugin dir: <GMT>/bin/gmt_plugins
library path: <GMT>/bin/gmt.dll
cores: 32
grid layout: rows
image layout:
binary version: 6.8.0
- Langage dominant
- Python
- Étoiles
- 882
- Forks
- 261
- Merge moyen
- 1 j 3 h
- PR mergées (30 j)
- 29
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de GenericMappingTools/pygmt
-
discussions documentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 78/100
GenericMappingTools/pygmt#4992 ·
Les mainteneurs répondent en général sous 1 jour
-
Improve reporting the GMT version via "pygmt.show_versions()"Peut-être pris @yvonnefroehlich l’a pris il y a 113 jours. Ouvertemaintenance
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
GenericMappingTools/pygmt#4812 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
GenericMappingTools/pygmt#4765 ·
Les mainteneurs répondent en général sous 1 jour
-
Add an AGENTS.md filePeut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. Ouvertediscussions
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
GenericMappingTools/pygmt#4677 · 2 commentaires · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
discussions maintenance
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
GenericMappingTools/pygmt#5006 · 2 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de GenericMappingTools/pygmt
Issues similaires
-
accepted
Difficulté 2/5 1-3 heures Accessibilité débutants 67/100
future-agi/future-agi#5274 ·
Les mainteneurs répondent en général sous 1 jour
-
Feed validator crashes with "Memory error" when validating https://www.tidyverse.org/index.xmlOuvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
w3c/feedvalidator#204 ·
-
[BUG][Low–Medium] founder_numbers.py silently reads a SAFE discount or pool target given as a fraction (0.2) as 0.2%Peut-être pris @sumitkhond111-del l’a pris aujourd’hui. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
bmad-code-org/BMAD-METHOD#3358 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
open-mmlab/mmcv#3352 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 68/100
OpenGithubs/weekly#263 ·
Les mainteneurs répondent en général sous 1 jour