[3.13] gh-119842: Honor PyOS_InputHook in the new REPL (GH-119843) (GH-120066)

(cherry picked from commit d9095194dd)

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>
This commit is contained in:
Łukasz Langa 2024-06-04 15:26:10 -04:00 committed by GitHub
parent 93b95e91fa
commit eea45ea213
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 144 additions and 11 deletions

View file

@ -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