]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
#14254: IDLE now handles readline correctly across shell restarts.
authorRoger Serwy <roger.serwy@gmail.com>
Wed, 3 Apr 2013 05:42:24 +0000 (00:42 -0500)
committerRoger Serwy <roger.serwy@gmail.com>
Wed, 3 Apr 2013 05:42:24 +0000 (00:42 -0500)
Lib/idlelib/PyShell.py
Misc/NEWS

index 41e746d78cae124fb95a1f5aecac6d02abf7f01e..c381f23b1e2c7e5296444200e1c91afb10dac434 100644 (file)
@@ -458,6 +458,7 @@ class ModifiedInterpreter(InteractiveInterpreter):
             self.display_no_subprocess_error()
             return None
         self.transfer_path(with_cwd=with_cwd)
+        console.stop_readline()
         # annotate restart in shell window and mark it
         console.text.delete("iomark", "end-1c")
         if was_executing:
@@ -896,6 +897,7 @@ class PyShell(OutputWindow):
     canceled = False
     endoffile = False
     closing = False
+    _stop_readline_flag = False
 
     def set_warning_stream(self, stream):
         global warning_stream
@@ -971,8 +973,7 @@ class PyShell(OutputWindow):
                 parent=self.text)
             if response is False:
                 return "cancel"
-        if self.reading:
-            self.top.quit()
+        self.stop_readline()
         self.canceled = True
         self.closing = True
         # Wait for poll_subprocess() rescheduling to stop
@@ -1027,6 +1028,12 @@ class PyShell(OutputWindow):
         tkinter._default_root = None # 03Jan04 KBK What's this?
         return True
 
+    def stop_readline(self):
+        if not self.reading:  # no nested mainloop to exit.
+            return
+        self._stop_readline_flag = True
+        self.top.quit()
+
     def readline(self):
         save = self.reading
         try:
@@ -1034,6 +1041,9 @@ class PyShell(OutputWindow):
             self.top.mainloop()  # nested mainloop()
         finally:
             self.reading = save
+        if self._stop_readline_flag:
+            self._stop_readline_flag = False
+            return ""
         line = self.text.get("iomark", "end-1c")
         if len(line) == 0:  # may be EOF if we quit our mainloop with Ctrl-C
             line = "\n"
index 8ffd9dee66bc06e474a9870dc053f9de29ab6212..621cdaa7e47dc41c3b913fd4c4d6e2570a5604ea 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,6 +19,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #14254: IDLE now handles readline correctly across shell restarts.
+
 - Issue #17614: IDLE no longer raises exception when quickly closing a file.
 
 - Issue #6698: IDLE now opens just an editor window when configured to do so.