]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-112938: IDLE - Fix uninteruptable hang when Shell gets rapid continuous output...
authorTerry Jan Reedy <tjreedy@udel.edu>
Sun, 22 Sep 2024 19:51:09 +0000 (15:51 -0400)
committerGitHub <noreply@github.com>
Sun, 22 Sep 2024 19:51:09 +0000 (15:51 -0400)
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.

Lib/idlelib/idle_test/test_outwin.py
Lib/idlelib/outwin.py
Misc/NEWS.d/next/IDLE/2024-09-21-23-12-18.gh-issue-112938.OeiDru.rst [new file with mode: 0644]

index d6e85ad674417c13bed1e95adf32ac83521382ee..81f4aad7e95e9557f0eb991b52f97f8e92d5011f 100644 (file)
@@ -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 @@ class OutputWindowTest(unittest.TestCase):
         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):
index 5ed3f35a7af65584870b6fd616a8efa7e0500453..8baa657550de948ab5ef215af3d1e21b24f936c0 100644 (file)
@@ -112,7 +112,7 @@ class OutputWindow(EditorWindow):
         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):
diff --git a/Misc/NEWS.d/next/IDLE/2024-09-21-23-12-18.gh-issue-112938.OeiDru.rst b/Misc/NEWS.d/next/IDLE/2024-09-21-23-12-18.gh-issue-112938.OeiDru.rst
new file mode 100644 (file)
index 0000000..0cd058e
--- /dev/null
@@ -0,0 +1 @@
+Fix uninteruptable hang when Shell gets rapid continuous output.