From c555666a51bfb9c9388ded4e939d7a03fac5a810 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Thu, 24 Sep 2026 07:43:36 +0300 Subject: [PATCH] gh-93966: Remove the syntax error highlighting in the IDLE Shell on the next statement (GH-157595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It stayed until the next syntax error. (cherry picked from commit 2483fb32062b99624303f6c203d5cbdba1de7cb3) Co-authored-by: Serhiy Storchaka Co-authored-by: André Roberge Co-authored-by: Claude Opus 5 (1M context) --- Lib/idlelib/pyshell.py | 3 ++- .../next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/IDLE/2026-09-15-22-10-17.gh-issue-93966.ch4fTB.rst diff --git a/Lib/idlelib/pyshell.py b/Lib/idlelib/pyshell.py index 5eb90e063e19583..dd4fe0d437c3d23 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.