Skip to content

Commit d5f95ec

Browse files
authored
gh-112938: IDLE - Fix uninteruptable hang when Shell gets rapid continuous output. (#124310)
#88496 replaced text.update with text.update_idletasks in colorizer.py and outwin.py to fix test failures on macOS. While theoretically correct, the result was Shell freezing when receiving continuous short strings to print. Test: `while 1: 1`. The guess is that there is no idle time in which to do the screen update. Reverting the change in one of the files, outwin, fixes the issue. Colorizer runs ever 1/20 second and seems to work fine. When running test-outwin on macOS, alias 'update' to 'update_idletasks on the text used for testing.
1 parent 342e654 commit d5f95ec

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

Lib/idlelib/idle_test/test_outwin.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"Test outwin, coverage 76%."
22

33
from idlelib import outwin
4+
import sys
45
import unittest
56
from test.support import requires
67
from tkinter import Tk, Text
@@ -18,6 +19,10 @@ def setUpClass(cls):
1819
root.withdraw()
1920
w = cls.window = outwin.OutputWindow(None, None, None, root)
2021
cls.text = w.text = Text(root)
22+
if sys.platform == 'darwin': # Issue 112938
23+
cls.text.update = cls.text.update_idletasks
24+
# Without this, test write, writelines, and goto... fail.
25+
# The reasons and why macOS-specific are unclear.
2126

2227
@classmethod
2328
def tearDownClass(cls):

Lib/idlelib/outwin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def write(self, s, tags=(), mark="insert"):
112112
assert isinstance(s, str)
113113
self.text.insert(mark, s, tags)
114114
self.text.see(mark)
115-
self.text.update_idletasks()
115+
self.text.update()
116116
return len(s)
117117

118118
def writelines(self, lines):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix uninteruptable hang when Shell gets rapid continuous output.

0 commit comments

Comments
 (0)