From d34b5fedc19dbd8766f87bd462e934312034c545 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 22 Sep 2024 22:07:52 +0200 Subject: [PATCH] [3.12] gh-112938: IDLE - Fix uninteruptable hang when Shell gets rapid continuous output. (GH-124310) (#124319) gh-112938: IDLE - Fix uninteruptable hang when Shell gets rapid continuous output. (GH-124310) https://github.com/python/cpython/issues/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. (cherry picked from commit 71afaa40ca50ea08600a217cd76fb554b58ca750) Co-authored-by: Terry Jan Reedy --- idlelib/idle_test/test_outwin.py | 5 +++++ idlelib/outwin.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/idlelib/idle_test/test_outwin.py b/idlelib/idle_test/test_outwin.py index d6e85ad6..81f4aad7 100644 --- a/idlelib/idle_test/test_outwin.py +++ b/idlelib/idle_test/test_outwin.py @@ -1,6 +1,7 @@ "Test outwin, coverage 76%." from idlelib import outwin +import sys import unittest from test.support import requires from tkinter import Tk, Text @@ -18,6 +19,10 @@ def setUpClass(cls): root.withdraw() w = cls.window = outwin.OutputWindow(None, None, None, root) cls.text = w.text = Text(root) + if sys.platform == 'darwin': # Issue 112938 + cls.text.update = cls.text.update_idletasks + # Without this, test write, writelines, and goto... fail. + # The reasons and why macOS-specific are unclear. @classmethod def tearDownClass(cls): diff --git a/idlelib/outwin.py b/idlelib/outwin.py index 5ed3f35a..8baa6575 100644 --- a/idlelib/outwin.py +++ b/idlelib/outwin.py @@ -112,7 +112,7 @@ def write(self, s, tags=(), mark="insert"): assert isinstance(s, str) self.text.insert(mark, s, tags) self.text.see(mark) - self.text.update_idletasks() + self.text.update() return len(s) def writelines(self, lines):