https://github.com/python/cpython/commit/8f7a6cf9fef03e0024b5a57184212dcc816523ad
commit: 8f7a6cf9fef03e0024b5a57184212dcc816523ad
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: serhiy-storchaka <[email protected]>
date: 2026-09-18T18:27:40Z
summary:

[3.13] gh-69365: Fix reference leak in IDLE search dialogs (GH-157754) 
(GH-157765)

Remove the variable trace that clears the error label when the label
is destroyed, so that it does not keep the dialog alive.
(cherry picked from commit b4067cd6e88f579e842e2b977d5bcbda69ba830c)

Co-authored-by: Serhiy Storchaka <[email protected]>

files:
M Lib/idlelib/searchbase.py

diff --git a/Lib/idlelib/searchbase.py b/Lib/idlelib/searchbase.py
index da96a047348094..9bb247a6c178c8 100644
--- a/Lib/idlelib/searchbase.py
+++ b/Lib/idlelib/searchbase.py
@@ -139,7 +139,11 @@ def create_error_label(self):
         self.error_label = Label(self.frame, text=' ', foreground='red')
         self.error_label.grid(row=self.row, column=1, sticky="nw")
         self.row = self.row + 1
-        self.engine.patvar.trace_add('write', lambda *args: 
self.show_error(''))
+        patvar = self.engine.patvar
+        trace = patvar.trace_add('write', lambda *args: self.show_error(''))
+        # The trace holds the dialog, remove it with the label.
+        self.error_label.bind('<Destroy>',
+                              lambda e: patvar.trace_remove('write', trace))
 
     def make_frame(self,labeltext=None):
         '''Return (frame, label).

_______________________________________________
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