diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 6e57e306a3678d9..c07b4027a17ab5e 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 "" 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 000000000000000..3260b42211b780b --- /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.