PyREPL: Send PS1 as string - #26197
Conversation
|
🔒 Automated review in progress — Rich Chiodo (@rchiodo) is auto-reviewing this PR. |
|
Result: Verification detailsVerification: Isolated verification observed failures that were not classified as caused by this PR: Wrapper idempotence and startup-global smoke checks. Summary: On Python 3.13.16, the targeted shell-integration file reported **11 passed**, including the PR’s new prompt-conversion test. Additional checks confirmed idempotent wrapping, single prompt conversions, and Python 3.11 compatibility. An actual-PS1 smoke check failed because this environment runs under WSL, where pythonrc deliberately suppresses sys.ps1; existing prompt-rendering tests also return early there. Verification is partial, with no observed PR-caused failure. Test runs: 3 passed, 1 failed
❌
|
Rich Chiodo (rchiodo)
left a comment
There was a problem hiding this comment.
Approved via Review Center.
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The reviewed changes include regression coverage and no unresolved issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Updates PyREPL integration to convert ps1 and ps2 prompts to strings before multiline input handling.
Changes:
- Wraps
_pyrepl.simple_interact.multiline_inputwith prompt conversion. - Adds regression coverage for non-string prompts.
| File | Description |
|---|---|
python_files/tests/test_shell_integration.py |
Tests prompt conversion behavior. |
python_files/pythonrc.py |
Adds the PyREPL prompt-conversion wrapper. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
7cd9ef3
into
main
Fixes #25467
Improve the integration of prompt handling in the REPL, ensuring that prompts are always passed as strings to
_pyrepl.simple_interact.multiline_inputpython_files/pythonrc.py, patch_pyrepl.simple_interact.multiline_inputso that theps1andps2prompt arguments are always converted to strings before being passed, preventing issues with non-string prompt objects (see gh-130698: Convertsys.ps1andsys.ps2to strings before PyREPL use python/cpython#158828)This makes sure that PS1 is converted to string even in python versions without the fix (e.g., 3.15.0r2 - 3.15.0)
Testing
test_pyrepl_multiline_input_converts_prompts_to_stringsinpython_files/tests/test_shell_integration.pyto verify that the patchedmultiline_inputfunction correctly converts prompt arguments to strings before calling the original function.