Type: Bug
What happened
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:
https://github.com/microsoft/vscode-python/blob/main/python_files/pythonrc.py#L49
def __str__(self):
exit_code = int(bool(self.hooks.failure_flag))
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
Type: Bug
What happened
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 intbrings it back.float = 10doesn't do this, onlyint. At first I thought it was a CPython bug,but it turned out to come from the Python extension.
Steps to reproduce
PYTHONSTARTUPpoints at the extension'spythonrc.py)python(3.13+ with the new PyREPL — also reproduces outside VS Code withPYTHONSTARTUP=/path/to/pythonrc.py python3.14)int = 20del intrestores it.Why it happens
pythonrc.pyinstalls a customsys.ps1whose__str__runs on every prompt:https://github.com/microsoft/vscode-python/blob/main/python_files/pythonrc.py#L49
Since
PYTHONSTARTUPexecutes inside the REPL's__main__, the method's__globals__IS the user's namespace. So after
int = 20, every prompt render calls20(False):When
str(sys.ps1)raises, PyREPL just doesn't render the prompt (CPython side of that is python/cpython#130698).floatis fine simply becausepythonrc.pynever calls it.Same thing happens with any other global the hooks touch at prompt time — e.g.
sys = 1also kills the prompt via
PS1.__str__→sys.platform.Possible fix
ps1object 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
fc3def6774c76082adf699d366f31a557ce5573f)python.terminal.shellIntegration.enabledat default