summaryrefslogtreecommitdiffstats
path: root/Lib/_pyrepl/reader.py
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2024-06-04 19:26:10 (GMT)
committerGitHub <noreply@github.com>2024-06-04 19:26:10 (GMT)
commiteea45ea21306fb04e5c4583889e8356315aa742b (patch)
tree15756aa6a3c337da4a09c0caae0dde10e9200782 /Lib/_pyrepl/reader.py
parent93b95e91faa17520f2042b4f4ae88379df914666 (diff)
downloadcpython-eea45ea21306fb04e5c4583889e8356315aa742b.zip
cpython-eea45ea21306fb04e5c4583889e8356315aa742b.tar.gz
cpython-eea45ea21306fb04e5c4583889e8356315aa742b.tar.bz2
[3.13] gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843) (GH-120066)
(cherry picked from commit d9095194dde27eaabfc0b86a11989cdb9a2acfe1) Signed-off-by: Pablo Galindo <pablogsal@gmail.com> Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: Michael Droettboom <mdboom@gmail.com>
Diffstat (limited to 'Lib/_pyrepl/reader.py')
-rw-r--r--Lib/_pyrepl/reader.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/_pyrepl/reader.py b/Lib/_pyrepl/reader.py
index 7839116..255967e 100644
--- a/Lib/_pyrepl/reader.py
+++ b/Lib/_pyrepl/reader.py
@@ -650,7 +650,15 @@ class Reader:
self.dirty = True
while True:
- event = self.console.get_event(block)
+ input_hook = self.console.input_hook
+ if input_hook:
+ input_hook()
+ # We use the same timeout as in readline.c: 100ms
+ while not self.console.wait(100):
+ input_hook()
+ event = self.console.get_event(block=False)
+ else:
+ event = self.console.get_event(block)
if not event: # can only happen if we're not blocking
return False