Skip to content

gh-130698: Convert sys.ps1 and sys.ps2 to strings before PyREPL use - #158828

Open
edvilme wants to merge 4 commits into
python:mainfrom
edvilme:pyrepl-str
Open

edvilme wants to merge 4 commits into
python:mainfrom
edvilme:pyrepl-str

Conversation

@edvilme

@edvilme edvilme commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Users may be able to assign non-string, but string representable values to sys.ps1 or sys.ps2, but these should be converted to their string representations before use by PyREPL rendering.

Otherwise, for users assigning non-string objects, or using tools like VSCode, the REPL overflows with errors.

…REPL use

Users may be able to assign non-string, but string representable values to ps1, but these should be converted to their string representations before use by PyREPL rendering.
@edvilme edvilme changed the title gh-158827: Convert sys.ps1 and sys.ps2 to strings before PyREPL use gh-130698: Convert sys.ps1 and sys.ps2 to strings before PyREPL use Oct 5, 2026
@edvilme edvilme changed the title gh-130698: Convert sys.ps1 and sys.ps2 to strings before PyREPL use gh-158827: Convert sys.ps1 and sys.ps2 to strings before PyREPL use Oct 5, 2026
@edvilme edvilme closed this Oct 5, 2026
@edvilme edvilme reopened this Oct 5, 2026
@edvilme edvilme changed the title gh-158827: Convert sys.ps1 and sys.ps2 to strings before PyREPL use gh-130698: Convert sys.ps1 and sys.ps2 to strings before PyREPL use Oct 5, 2026
@sergey-miryanov

Copy link
Copy Markdown
Contributor

It would be good to fix original issue as well.

Comment thread Misc/NEWS.d/next/Library/2026-10-05-08-35-10.gh-issue-130698.iibO9V.rst Outdated
@brettcannon brettcannon added type-bug An unexpected behavior, bug, or error needs backport to 3.15 pre-release feature fixes, bugs and security fixes labels Oct 5, 2026
…ibO9V.rst

Co-authored-by: Brett Cannon <brett@python.org>
edvilme added a commit to microsoft/vscode-python that referenced this pull request Oct 5, 2026
Improve the integration of prompt handling in the REPL, ensuring that
prompts are always passed as strings to
`_pyrepl.simple_interact.multiline_input`

* In `python_files/pythonrc.py`, patch
`_pyrepl.simple_interact.multiline_input` so that the `ps1` and `ps2`
prompt arguments are always converted to strings before being passed,
preventing issues with non-string prompt objects (see
python/cpython#158828)

### Testing

* Adds a new test
`test_pyrepl_multiline_input_converts_prompts_to_strings` in
`python_files/tests/test_shell_integration.py` to verify that the
patched `multiline_input` function correctly converts prompt arguments
to strings before calling the original function.
@edvilme
edvilme requested a review from brettcannon October 5, 2026 17:38
@brettcannon brettcannon added the needs backport to 3.14 bugs and security fixes label Oct 6, 2026
@brettcannon

Copy link
Copy Markdown
Member

@sergey-miryanov we need a fix for the str usage as it's causes issues in VS Code, so I would rather get this targeted fix in now while we wait to get a decision on what to do in the face of exceptions back on the original issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting merge needs backport to 3.14 bugs and security fixes needs backport to 3.15 pre-release feature fixes, bugs and security fixes type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants