gh-69365: Fix reference leak in IDLE search dialogs (GH-157754)

Remove the variable trace that clears the error label when the label
is destroyed, so that it does not keep the dialog alive.
This commit is contained in:
Serhiy Storchaka authored and GitHub committed 2026-09-18 21:03:47 +03:00
1 parent 76f22f9cf2
commit b4067cd6e8
1 file changed
+5 -1
+5 -1
View File
@@ -139,7 +139,11 @@ class SearchDialogBase:
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).