Skip to content

Commit 56e162a

Browse files
authored
ttk: fix LabeledScale and OptionMenu destroy() method (#3026)
bpo-31135: Call the parent destroy() method even if the used attribute doesn't exist. The LabeledScale.destroy() method now also explicitly clears label and scale attributes to help the garbage collector to destroy all widgets.
1 parent 245dafc commit 56e162a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

Lib/lib-tk/ttk.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,9 @@ def destroy(self):
15211521
pass
15221522
else:
15231523
del self._variable
1524-
Frame.destroy(self)
1524+
Frame.destroy(self)
1525+
self.label = None
1526+
self.scale = None
15251527

15261528

15271529
def _adjust(self, *args):
@@ -1620,5 +1622,8 @@ def set_menu(self, default=None, *values):
16201622

16211623
def destroy(self):
16221624
"""Destroy this widget and its associated variable."""
1623-
del self._variable
1625+
try:
1626+
del self._variable
1627+
except AttributeError:
1628+
pass
16241629
Menubutton.destroy(self)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ttk: Fix LabeledScale and OptionMenu destroy() method. Call the parent
2+
destroy() method even if the used attribute doesn't exist. The
3+
LabeledScale.destroy() method now also explicitly clears label and scale
4+
attributes to help the garbage collector to destroy all widgets.

0 commit comments

Comments
 (0)