Skip to content

Commit d2186e5

Browse files
committed
The GUI was hanging if the shell window was closed while a raw_input()
was pending. Restored the quit() of the readline() mainloop(). http://mail.python.org/pipermail/idle-dev/2004-December/002307.html M NEWS.txt M PyShell.py
1 parent 64d7771 commit d2186e5

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

Lib/idlelib/NEWS.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
What's New in IDLE 1.0.4?
22
=========================
33

4-
*Release date: XX-XXX-2004*
4+
*Release date: XX-Dec-2004*
5+
6+
- The GUI was hanging if the shell window was closed while a raw_input()
7+
was pending. Restored the quit() of the readline() mainloop().
8+
http://mail.python.org/pipermail/idle-dev/2004-December/002307.html
59

610
- Added a Tk error dialog to run.py inform the user if the subprocess can't
711
connect to the user GUI process. Added a timeout to the GUI's listening

Lib/idlelib/PyShell.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,9 @@ def close(self):
877877
parent=self.text)
878878
if response == False:
879879
return "cancel"
880+
if self.reading:
881+
self.top.quit()
882+
self.canceled = True
880883
self.closing = True
881884
# Wait for poll_subprocess() rescheduling to stop
882885
self.text.after(2 * self.pollinterval, self.close2)
@@ -941,10 +944,12 @@ def readline(self):
941944
save = self.reading
942945
try:
943946
self.reading = 1
944-
self.top.mainloop()
947+
self.top.mainloop() # nested mainloop()
945948
finally:
946949
self.reading = save
947950
line = self.text.get("iomark", "end-1c")
951+
if len(line) == 0: # may be EOF if we quit our mainloop with Ctrl-C
952+
line = "\n"
948953
if isinstance(line, unicode):
949954
import IOBinding
950955
try:
@@ -954,10 +959,11 @@ def readline(self):
954959
self.resetoutput()
955960
if self.canceled:
956961
self.canceled = 0
957-
raise KeyboardInterrupt
962+
if not use_subprocess:
963+
raise KeyboardInterrupt
958964
if self.endoffile:
959965
self.endoffile = 0
960-
return ""
966+
line = ""
961967
return line
962968

963969
def isatty(self):
@@ -976,13 +982,13 @@ def cancel_callback(self, event=None):
976982
return "break"
977983
self.endoffile = 0
978984
self.canceled = 1
979-
if self.reading:
980-
self.top.quit()
981-
elif (self.executing and self.interp.rpcclt):
985+
if (self.executing and self.interp.rpcclt):
982986
if self.interp.getdebugger():
983987
self.interp.restart_subprocess()
984988
else:
985989
self.interp.interrupt_subprocess()
990+
if self.reading:
991+
self.top.quit() # exit the nested mainloop() in readline()
986992
return "break"
987993

988994
def eof_callback(self, event):

0 commit comments

Comments
 (0)