[Python-checkins] cpython (2.7): #14254: IDLE now handles readline correctly across shell restarts.

roger.serwy python-checkins at python.org
Wed Apr 3 07:44:57 CEST 2013


http://hg.python.org/cpython/rev/097554712637
changeset:   83072:097554712637
branch:      2.7
parent:      83069:1e5e497ee33b
user:        Roger Serwy <roger.serwy at gmail.com>
date:        Wed Apr 03 00:42:24 2013 -0500
summary:
  #14254: IDLE now handles readline correctly across shell restarts.

files:
  Lib/idlelib/PyShell.py |  14 ++++++++++++--
  Misc/NEWS              |   2 ++
  2 files changed, 14 insertions(+), 2 deletions(-)


diff --git a/Lib/idlelib/PyShell.py b/Lib/idlelib/PyShell.py
--- a/Lib/idlelib/PyShell.py
+++ b/Lib/idlelib/PyShell.py
@@ -469,6 +469,7 @@
             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:
@@ -908,6 +909,7 @@
     canceled = False
     endoffile = False
     closing = False
+    _stop_readline_flag = False
 
     def set_warning_stream(self, stream):
         global warning_stream
@@ -983,8 +985,7 @@
                 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
@@ -1036,6 +1037,12 @@
         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:
@@ -1043,6 +1050,9 @@
             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"
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@
 Library
 -------
 
+- Issue #14254: IDLE now handles readline correctly across shell restarts.
+
 - Issue #17614: IDLE no longer raises exception when quickly closing a file.
 
 - Issue #13163: Rename operands in smtplib.SMTP._get_socket to correct names;

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list