Repository navigation
fix: quote the default {python} run substitution for the shell - #797
Open
yarikoptic-gitmate wants to merge 2 commits into
Open
yarikoptic-gitmate wants to merge 2 commits into
yarikoptic-gitmate wants to merge 2 commits into
Conversation
`run` hands the formatted command to the shell as a single string, but
the default value of `datalad.run.substitutions.python` was the bare
`sys.executable`. An interpreter path containing a space (e.g. hatch's
"~/Library/Application Support/..." on macOS, or "C:\Program Files\..."
on Windows) was split by the shell, and the command failed with exit
code 127.
Quote the default with `quote_cmdlinearg()`, as `format_command()`
already does for `{inputs}` and `{outputs}`: `shlex.quote()` on POSIX
(a no-op for paths without special characters), double quotes on
Windows, where the string is run by cmd.exe. Values that users
configure are still inserted verbatim, like any other substitution,
hence are not double-quoted.
Commands that worked around the bug by putting `{python}` in double
quotes themselves now get the default quoted twice; this includes run
records that `rerun` executes again. On POSIX, such a command now
fails for an interpreter path that needs quoting, where it worked
before. On Windows, where the default is always double-quoted, it now
gets doubled quotes, which cmd.exe may not run.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PvaGRXnrnSEHAKqfFZHw7Z
With the default `{python}` substitution quoted, a space in the path of
hatch's environments ("~/Library/Application Support" on macOS) no
longer breaks `run`. HATCH_DATA_DIR is still set as on AppVeyor.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PvaGRXnrnSEHAKqfFZHw7Z
yarikoptic
force-pushed
the
claude/sharp-cori-nnzq30-run-python-quote
branch
from
November 11, 2026 14:22
575b118 to
e7d4aa1
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #797 +/- ##
==========================================
- Coverage 90.89% 90.53% -0.36%
==========================================
Files 182 182
Lines 12218 12218
Branches 1252 1252
==========================================
- Hits 11105 11062 -43
- Misses 869 894 +25
- Partials 244 262 +18 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
datalad run '{python} -c "True"'fails with exit code 127 when the interpreter path contains a space. Examples are hatch's environments under~/Library/Application Support/...on macOS, orC:\Program Files\...on Windows.runhands the formatted command to the shell as one string, but the default ofdatalad.run.substitutions.pythonwas the baresys.executable, so the shell split the path. This showed in the new GitHub workflow's macOS job as atest_substitution_config_defaultfailure. #796 worked around it there by settingHATCH_DATA_DIR, as AppVeyor does.Changes
fix:patches/run.py: the default is nowquote_cmdlinearg(sys.executable), asformat_command()already does for{inputs}/{outputs}, and as core'srun_proceduredoes forsys.executable.shlex.quote(), a no-op for paths without special characters.ci:.github/workflows/test.yml: drops the now-stale reason given forHATCH_DATA_DIR. The variable is still set, because.appveyor.ymlsets it on all three platforms.Behaviour change
Commands that worked around the bug by writing
"{python}"in quotes now get the default quoted twice. That includes run records re-executed byrerun.Testing
test_substitution_config_defaultfails onmainand passes with this PR, run from a venv under a path with a space. CI has no such path.cz checkis clean.Three independent AI reviewers approved this change.
Generated by Claude Code