aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/_pyrepl/simple_interact.py
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2025-01-21 22:04:30 +0100
committerGitHub <noreply@github.com>2025-01-21 21:04:30 +0000
commit5a9afe23620aadea30013076d64686be8bf66f7e (patch)
tree0e66b1b514c1a8903ad876c688b838ffd76f582e /Lib/_pyrepl/simple_interact.py
parentd147e5e52cdb90496ae5fe85b3263cdfa9407a28 (diff)
downloadcpython-5a9afe23620aadea30013076d64686be8bf66f7e.tar.gz
cpython-5a9afe23620aadea30013076d64686be8bf66f7e.zip
gh-123024: Correctly prepare/restore around help and show-history commands (#124485)
Co-authored-by: Emily Morehouse <emily@cuttlesoft.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/_pyrepl/simple_interact.py')
-rw-r--r--Lib/_pyrepl/simple_interact.py16
1 files changed, 4 insertions, 12 deletions
diff --git a/Lib/_pyrepl/simple_interact.py b/Lib/_pyrepl/simple_interact.py
index a5033496712..a065174ad42 100644
--- a/Lib/_pyrepl/simple_interact.py
+++ b/Lib/_pyrepl/simple_interact.py
@@ -77,7 +77,7 @@ REPL_COMMANDS = {
"exit": _sitebuiltins.Quitter('exit', ''),
"quit": _sitebuiltins.Quitter('quit' ,''),
"copyright": _sitebuiltins._Printer('copyright', sys.copyright),
- "help": "help",
+ "help": _sitebuiltins._Helper(),
"clear": _clear_screen,
"\x1a": _sitebuiltins.Quitter('\x1a', ''),
}
@@ -124,18 +124,10 @@ def run_multiline_interactive_console(
reader.history.pop() # skip internal commands in history
command = REPL_COMMANDS[statement]
if callable(command):
- command()
+ # Make sure that history does not change because of commands
+ with reader.suspend_history():
+ command()
return True
-
- if isinstance(command, str):
- # Internal readline commands require a prepared reader like
- # inside multiline_input.
- reader.prepare()
- reader.refresh()
- reader.do_cmd((command, [statement]))
- reader.restore()
- return True
-
return False
while True: