Skip to content

Add args parameter to REPLWrapper to support executable paths with spaces#377

Merged
blink1073 merged 4 commits intoCalysto:mainfrom
blink1073:finish-281
Mar 15, 2026
Merged

Add args parameter to REPLWrapper to support executable paths with spaces#377
blink1073 merged 4 commits intoCalysto:mainfrom
blink1073:finish-281

Conversation

@blink1073
Copy link
Copy Markdown
Contributor

References

Replaces and closes #281.

Description

PR #281 by @tikuma-lsuhsc proposed adding an args parameter to REPLWrapper to allow passing additional arguments to the spawned command. This is needed to support executable paths containing spaces on Windows (e.g. an Octave installation in C:\Program Files\...).

This PR implements the same feature with the correct fix for the non-pty codepath.

Changes

  • metakernel/replwrap.py: Added args: list[str] | None = None parameter to REPLWrapper.__init__; passed through to pexpect.spawnu.
  • metakernel/pexpect.py: On the non-pty (Windows/PopenSpawn) path, skip shlex.split when args is explicitly provided — instead use [command] + args. This matches the pty_spawn behaviour and allows the command to be a literal executable path (with spaces) rather than a shell-split string.
  • tests/test_replwrap.py: Added test_spawn_args test that starts a Python REPL with args=["-i", "-c", "x=4+7"] and verifies the result.
  • tests/test_replwrap_init.py: Updated two mock assertions to expect the new args=None keyword argument in spawnu calls.

Backwards-incompatible changes

None. The new args parameter defaults to None and existing behaviour is unchanged when it is not supplied.

Testing

Existing test suite passes. New test_spawn_args test added to tests/test_replwrap.py.

AI usage

  • This PR contains AI-generated content (Claude Sonnet 4.6 via Claude Code)

…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.
@blink1073 blink1073 enabled auto-merge (squash) March 14, 2026 22:23
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.82%. Comparing base (7cc937b) to head (b4484f3).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@blink1073 blink1073 disabled auto-merge March 15, 2026 02:02
@blink1073 blink1073 merged commit f9f5e94 into Calysto:main Mar 15, 2026
25 of 27 checks passed
@blink1073 blink1073 mentioned this pull request Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant