]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-121497: Make Pyrepl respect correctly the history with input hook set ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sat, 13 Jul 2024 14:28:49 +0000 (16:28 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Jul 2024 14:28:49 +0000 (14:28 +0000)
gh-121497: Make Pyrepl respect correctly the history with input hook set (GH-121498)
(cherry picked from commit 4e36dd7d87eb0f1bd1ecd53e368c16a5f75967a0)

Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com>
Lib/_pyrepl/unix_console.py
Misc/NEWS.d/next/Core and Builtins/2024-07-08-17-15-14.gh-issue-121497.I8hMDC.rst [new file with mode: 0644]

index c4dedd97d1e13d5f1a652111c5d01d5825bd14d3..18b2bba91c8c9b73d9a8730067b4eceaeb7ff046 100644 (file)
@@ -383,6 +383,8 @@ class UnixConsole(Console):
         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 @@ class UnixConsole(Console):
                         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 (file)
index 0000000..33de31a
--- /dev/null
@@ -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