Add args parameter to REPLWrapper to support executable paths with spaces#377
Merged
blink1073 merged 4 commits intoCalysto:mainfrom Mar 15, 2026
Merged
Add args parameter to REPLWrapper to support executable paths with spaces#377blink1073 merged 4 commits intoCalysto:mainfrom
blink1073 merged 4 commits intoCalysto:mainfrom
Conversation
…h spaces (closes Calysto#281) Adds an `args` list parameter to `REPLWrapper.__init__` and passes it through to `pexpect.spawnu`. On the non-pty (Windows) codepath, the command is no longer shlex-split when `args` is explicitly provided, matching the pty_spawn behaviour and allowing executable paths containing spaces to work correctly.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #377 +/- ##
=======================================
Coverage 90.82% 90.82%
=======================================
Files 51 51
Lines 2943 2944 +1
Branches 410 411 +1
=======================================
+ Hits 2673 2674 +1
Misses 190 190
Partials 80 80 ☔ View full report in Codecov by Sentry. 🚀 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.
References
Replaces and closes #281.
Description
PR #281 by @tikuma-lsuhsc proposed adding an
argsparameter toREPLWrapperto allow passing additional arguments to the spawned command. This is needed to support executable paths containing spaces on Windows (e.g. an Octave installation inC:\Program Files\...).This PR implements the same feature with the correct fix for the non-pty codepath.
Changes
metakernel/replwrap.py: Addedargs: list[str] | None = Noneparameter toREPLWrapper.__init__; passed through topexpect.spawnu.metakernel/pexpect.py: On the non-pty (Windows/PopenSpawn) path, skipshlex.splitwhenargsis explicitly provided — instead use[command] + args. This matches thepty_spawnbehaviour and allows the command to be a literal executable path (with spaces) rather than a shell-split string.tests/test_replwrap.py: Addedtest_spawn_argstest that starts a Python REPL withargs=["-i", "-c", "x=4+7"]and verifies the result.tests/test_replwrap_init.py: Updated two mock assertions to expect the newargs=Nonekeyword argument inspawnucalls.Backwards-incompatible changes
None. The new
argsparameter defaults toNoneand existing behaviour is unchanged when it is not supplied.Testing
Existing test suite passes. New
test_spawn_argstest added totests/test_replwrap.py.AI usage