You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Terminal REPL: >>> prompt disappears after assigning to int (pythonrc.py PS1 breaks when builtins are shadowed) #26039
I was playing around in the REPL inside VS Code's integrated terminal and noticed that after int = 20, the >>> prompt just stops showing up. del int brings it back.
Python 3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)] on darwin Type "help", "copyright", "credits" or "license" for more information.
Cmd click to launch VS Code Native REPL
>>> int=20
print(int) # <- no ">>> " prompt is rendered anymore
20
del int
>>>
float = 10 doesn't do this, only int. At first I thought it was a CPython bug,
but it turned out to come from the Python extension.
Steps to reproduce
Open the integrated terminal with the Python extension installed (so PYTHONSTARTUP points at the extension's pythonrc.py)
Run python (3.13+ with the new PyREPL — also reproduces outside VS Code with PYTHONSTARTUP=/path/to/pythonrc.py python3.14)
int = 20
Prompt is gone. del int restores it.
Why it happens
pythonrc.py installs a custom sys.ps1 whose __str__ runs on every prompt:
Since PYTHONSTARTUP executes inside the REPL's __main__, the method's __globals__
IS the user's namespace. So after int = 20, every prompt render calls 20(False):
File ".../_pyrepl/reader.py", line 495, in get_prompt
prompt = f"{t.prompt}{prompt}{t.reset}"
File ".../pythonrc.py", line 49, in __str__
exit_code = int(bool(self.hooks.failure_flag))
TypeError: 'int' object is not callable
When str(sys.ps1) raises, PyREPL just doesn't render the prompt (CPython side of that is python/cpython#130698). float is fine simply because pythonrc.py never calls it.
Same thing happens with any other global the hooks touch at prompt time — e.g. sys = 1
also kills the prompt via PS1.__str__ → sys.platform.
Possible fix
capture the builtins/modules at definition time (default args or an alias made at startup), or
run the shell-integration code in an actual separate module and only put the ps1
object into __main__
(#25651 / #25904 look related but cover the opposite direction — pythonrc leaking into
the user namespace. Wrapping pythonrc in a function alone wouldn't fix this one, since a
class defined in a function still resolves its methods' globals through __main__.)
Environment
VS Code 1.128.0 (fc3def6774c76082adf699d366f31a557ce5573f)
ms-python.python 2026.4.0
macOS (Darwin 25.5.0), arm64
Python 3.14.6 (Homebrew), new PyREPL
python.terminal.shellIntegration.enabled at default
Hello mumallaeng (@mumallaeng) thanks for bringing this to our attention. This issue should be solved by PR #26045 now
Please don't hesitate to reach out if the issue persists in the next release
Activity
mohityadav8 commentedon Jul 12, 2026
Karthik Nadig (@karthiknadig) assign this to me let me work on thsi
karthiknadig commentedon Jul 12, 2026
Go for it Mohit Yadav (@mohityadav8) . We don’t assign non-team members for tracking.
mohityadav8 commentedon Jul 16, 2026
/working
mohityadav8 commentedon Jul 19, 2026
Karthik Nadig (@karthiknadig) solved this issue in pr #26045
Fix #26039: REPL prompt disappears when builtins/globals shadowed und…
edvilme commentedon Sep 16, 2026
Hello mumallaeng (@mumallaeng) thanks for bringing this to our attention. This issue should be solved by PR #26045 now
Please don't hesitate to reach out if the issue persists in the next release
Fix microsoft#26039: REPL prompt disappears when builtins/globals sha…