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
Data entered through input() in REPL is written to ~/.python_history #159225
[adrian@eluvian:~]>pythonPython3.15.0 (main, Oct92026, 23:29:57) [GCC16.2.120260926] onlinuxType"help", "copyright", "credits"or"license"formoreinformation.
>>>input()
helloworld, thismaybesecret!
'hello world, this may be secret!'>>>
[adrian@eluvian:~]>tail-n2~/.python_historyinput()
helloworld, thismaybesecret!
I know there's getpass.getpass() for secrets, but I'm sure it's not uncommon that people just run quick&dirty snippeds in the python repl where they use input() to enter a password without expecting it to be written to their history.
The security aspect aside, it also feels very dirty because unlike the rest of content in the history file, a line entered through input() is very unlikely to make sense when executed as python code (e.g. from the REPL history).
This appears related to #71057, but could we verify whether readline.set_auto_history(False) also prevents input() responses from being recorded when using the default PyREPL? PyREPL has a separate history implementation, so the behavior may differ.
I tried it on 3.14.8 with the default REPL and PYTHON_HISTORY pointed at a temp file. readline.set_auto_history(False) doesn't help there, the input() reply still ends up in the history file. PyREPL replaces builtins.input with its own reader (readline.py#L640-L641), and that reader appends every line to the shared history (historical_reader.py#L411-L412), so the C module's flag is never consulted.
The private _pyrepl.readline.set_auto_history(False) does stop it, but it turns off history for everything typed afterwards, not just input(). Same with the C module under PYTHON_BASIC_REPL=1. So right now there's no way to skip only the input() lines.
I wonder if the behavior we want is to disable history while on input() mode, or if we should still allow using up/down arrows while on input() mode but just not adding anything to it
Activity
hugovk commentedon Oct 12, 2026
Duplicate of #71057?
BHUVANSH855 commentedon Oct 12, 2026
This appears related to #71057, but could we verify whether
readline.set_auto_history(False)also preventsinput()responses from being recorded when using the default PyREPL? PyREPL has a separate history implementation, so the behavior may differ.lazerg commentedon Oct 12, 2026
I tried it on 3.14.8 with the default REPL and
PYTHON_HISTORYpointed at a temp file.readline.set_auto_history(False)doesn't help there, theinput()reply still ends up in the history file. PyREPL replacesbuiltins.inputwith its own reader (readline.py#L640-L641), and that reader appends every line to the shared history (historical_reader.py#L411-L412), so the C module's flag is never consulted.The private
_pyrepl.readline.set_auto_history(False)does stop it, but it turns off history for everything typed afterwards, not justinput(). Same with the C module underPYTHON_BASIC_REPL=1. So right now there's no way to skip only theinput()lines.edvilme commentedon Oct 12, 2026
Hi if people are not planning to already, would love to work on this :)
edvilme commentedon Oct 12, 2026
I wonder if the behavior we want is to disable history while on
input()mode, or if we should still allow using up/down arrows while oninput()mode but just not adding anything to itpythongh-159225: Cover input history isolation and interrupted reads
gh-159225: PyREPL input should not write to history (#159263)
[3.14] gh-159225: PyREPL input should not write to history (GH-159263) (
[3.15] gh-159225: PyREPL input should not write to history (GH-159263) (