diff -r 6ad256175971 Lib/idlelib/PyShell.py --- a/Lib/idlelib/PyShell.py Sun Mar 31 15:56:02 2013 -0500 +++ b/Lib/idlelib/PyShell.py Sun Mar 31 17:44:37 2013 -0500 @@ -446,6 +446,9 @@ self.terminate_subprocess() console = self.tkconsole was_executing = console.executing + if console.reading: + console.endoffile = True + console.top.quit() console.executing = False self.spawn_subprocess() try: @@ -967,10 +970,10 @@ parent=self.text) if response is False: return "cancel" + self.canceled = True + self.closing = True if self.reading: self.top.quit() - self.canceled = True - self.closing = True # Wait for poll_subprocess() rescheduling to stop self.text.after(2 * self.pollinterval, self.close2) @@ -1033,6 +1036,8 @@ self.top.mainloop() # nested mainloop() finally: self.reading = save + if self.closing: + return "" # return EOF for the closing process line = self.text.get("iomark", "end-1c") if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C line = "\n"