diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-31 08:35:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-31 08:35:21 (GMT) |
commit | 8470593a98a5f17d72bea0df8287f43ba4f7f627 (patch) | |
tree | e761a05f2d60a5ad4510ddcdb42b4cc9f051e3f2 /Lib/_pyrepl/reader.py | |
parent | 978b86a91e381bf7cc987ac3e44b0251e4a474ba (diff) | |
download | cpython-8470593a98a5f17d72bea0df8287f43ba4f7f627.zip cpython-8470593a98a5f17d72bea0df8287f43ba4f7f627.tar.gz cpython-8470593a98a5f17d72bea0df8287f43ba4f7f627.tar.bz2 |
[3.13] gh-119548: Add a 'clear' command to the REPL (GH-119549) (#119552)
gh-119548: Add a 'clear' command to the REPL (GH-119549)
(cherry picked from commit e3bac04c37f6823cebc74d97feae0e0c25818b31)
Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Diffstat (limited to 'Lib/_pyrepl/reader.py')
-rw-r--r-- | Lib/_pyrepl/reader.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py index 0f0ef15..1c816d5 100644 --- a/Lib/_pyrepl/reader.py +++ b/Lib/_pyrepl/reader.py @@ -238,6 +238,7 @@ class Reader: cxy: tuple[int, int] = field(init=False) lxy: tuple[int, int] = field(init=False) calc_screen: CalcScreen = field(init=False) + scheduled_commands: list[str] = field(default_factory=list) def __post_init__(self) -> None: # Enable the use of `insert` without a `prepare` call - necessary to @@ -557,6 +558,10 @@ class Reader: self.restore() raise + while self.scheduled_commands: + cmd = self.scheduled_commands.pop() + self.do_cmd((cmd, [])) + def last_command_is(self, cls: type) -> bool: if not self.last_command: return False |