mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
[3.13] gh-123024: Correctly prepare/restore around help and show-history commands (GH-124485) (#129155)
gh-123024: Correctly prepare/restore around help and show-history commands (GH-124485)
(cherry picked from commit 5a9afe2362
)
Co-authored-by: Lysandros Nikolaou <lisandrosnik@gmail.com>
Co-authored-by: Emily Morehouse <emily@cuttlesoft.com>
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
This commit is contained in:
parent
3048dcd15a
commit
0ddcb61ffe
7 changed files with 77 additions and 57 deletions
|
@ -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 1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue