@@ -458,6 +458,7 @@ def restart_subprocess(self, with_cwd=False):
458458 self .display_no_subprocess_error ()
459459 return None
460460 self .transfer_path (with_cwd = with_cwd )
461+ console .stop_readline ()
461462 # annotate restart in shell window and mark it
462463 console .text .delete ("iomark" , "end-1c" )
463464 if was_executing :
@@ -896,6 +897,7 @@ def get_standard_extension_names(self):
896897 canceled = False
897898 endoffile = False
898899 closing = False
900+ _stop_readline_flag = False
899901
900902 def set_warning_stream (self , stream ):
901903 global warning_stream
@@ -971,8 +973,7 @@ def close(self):
971973 parent = self .text )
972974 if response is False :
973975 return "cancel"
974- if self .reading :
975- self .top .quit ()
976+ self .stop_readline ()
976977 self .canceled = True
977978 self .closing = True
978979 # Wait for poll_subprocess() rescheduling to stop
@@ -1027,13 +1028,22 @@ def begin(self):
10271028 tkinter ._default_root = None # 03Jan04 KBK What's this?
10281029 return True
10291030
1031+ def stop_readline (self ):
1032+ if not self .reading : # no nested mainloop to exit.
1033+ return
1034+ self ._stop_readline_flag = True
1035+ self .top .quit ()
1036+
10301037 def readline (self ):
10311038 save = self .reading
10321039 try :
10331040 self .reading = 1
10341041 self .top .mainloop () # nested mainloop()
10351042 finally :
10361043 self .reading = save
1044+ if self ._stop_readline_flag :
1045+ self ._stop_readline_flag = False
1046+ return ""
10371047 line = self .text .get ("iomark" , "end-1c" )
10381048 if len (line ) == 0 : # may be EOF if we quit our mainloop with Ctrl-C
10391049 line = "\n "
0 commit comments