https://github.com/python/cpython/commit/4e36dd7d87eb0f1bd1ecd53e368c16a5f75967a0
commit: 4e36dd7d87eb0f1bd1ecd53e368c16a5f75967a0
branch: main
author: Pablo Galindo Salgado <[email protected]>
committer: pablogsal <[email protected]>
date: 2024-07-13T09:42:14Z
summary:

gh-121497: Make Pyrepl respect correctly the history with input hook set 
(#121498)

files:
A Misc/NEWS.d/next/Core and 
Builtins/2024-07-08-17-15-14.gh-issue-121497.I8hMDC.rst
M Lib/_pyrepl/unix_console.py

diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py
index c4dedd97d1e13d..18b2bba91c8c9b 100644
--- a/Lib/_pyrepl/unix_console.py
+++ b/Lib/_pyrepl/unix_console.py
@@ -383,6 +383,8 @@ def get_event(self, block: bool = True) -> Event | None:
         Returns:
         - Event: Event object from the event queue.
         """
+        if not block and not self.wait(timeout=0):
+            return None
         while self.event_queue.empty():
             while True:
                 try:
@@ -397,8 +399,6 @@ def get_event(self, block: bool = True) -> Event | None:
                         raise
                 else:
                     break
-            if not block:
-                break
         return self.event_queue.get()
 
     def wait(self, timeout: float | None = None) -> bool:
diff --git a/Misc/NEWS.d/next/Core and 
Builtins/2024-07-08-17-15-14.gh-issue-121497.I8hMDC.rst b/Misc/NEWS.d/next/Core 
and Builtins/2024-07-08-17-15-14.gh-issue-121497.I8hMDC.rst
new file mode 100644
index 00000000000000..33de31abebe7c7
--- /dev/null
+++ b/Misc/NEWS.d/next/Core and 
Builtins/2024-07-08-17-15-14.gh-issue-121497.I8hMDC.rst 
@@ -0,0 +1,2 @@
+Fix a bug that was preventing the REPL to correctly respect the history when
+an input hook was set. Patch by Pablo Galindo

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to