Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b7a5ae

Browse files
committed
#14254: IDLE now handles readline correctly across shell restarts.
1 parent 0d28a61 commit 6b7a5ae

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

Lib/idlelib/PyShell.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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"

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Core and Builtins
1919
Library
2020
-------
2121

22+
- Issue #14254: IDLE now handles readline correctly across shell restarts.
23+
2224
- Issue #17614: IDLE no longer raises exception when quickly closing a file.
2325

2426
- Issue #6698: IDLE now opens just an editor window when configured to do so.

0 commit comments

Comments
 (0)