https://github.com/python/cpython/commit/b845c02c9ddbbfeb9418431941c07fb2fb6ba98b
commit: b845c02c9ddbbfeb9418431941c07fb2fb6ba98b
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-09-28T18:56:44+03:00
summary:

[3.15] gh-93966: Remove the syntax error highlighting in the IDLE Shell on the 
next statement (GH-157595) (#158057)

Co-authored-by: Serhiy Storchaka <[email protected]>
Co-authored-by: AndrĂ© Roberge <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

files:
A Misc/NEWS.d/next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst
M Lib/idlelib/pyshell.py

diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py
index 5eb90e063e1958..dd4fe0d437c3d2 100755
--- a/Lib/idlelib/pyshell.py
+++ b/Lib/idlelib/pyshell.py
@@ -694,6 +694,8 @@ def execfile(self, filename, source=None):
 
     def runsource(self, source):
         "Extend base class method: Stuff the source in the line cache first"
+        # Remove the highlighting of a previous syntax error (gh-93966).
+        self.tkconsole.text.tag_remove("ERROR", "1.0", "end")
         filename = self.stuffsource(source)
         # at the moment, InteractiveInterpreter expects str
         assert isinstance(source, str)
@@ -730,7 +732,6 @@ def showsyntaxerror(self, filename=None, **kwargs):
         """
         tkconsole = self.tkconsole
         text = tkconsole.text
-        text.tag_remove("ERROR", "1.0", "end")
         type, value, tb = sys.exc_info()
         msg = getattr(value, 'msg', '') or value or "<no detail available>"
         lineno = getattr(value, 'lineno', '') or 1
diff --git 
a/Misc/NEWS.d/next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst 
b/Misc/NEWS.d/next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst
new file mode 100644
index 00000000000000..3260b42211b780
--- /dev/null
+++ b/Misc/NEWS.d/next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst
@@ -0,0 +1,2 @@
+The highlighting of a syntax error in the IDLE Shell is now removed when the
+next statement is entered, not only when the next syntax error occurs.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to