]> granicus.if.org Git - python/commitdiff
ttk: fix LabeledScale and OptionMenu destroy() method (#3026)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 8 Aug 2017 17:15:52 +0000 (19:15 +0200)
committerGitHub <noreply@github.com>
Tue, 8 Aug 2017 17:15:52 +0000 (19:15 +0200)
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.

Lib/lib-tk/ttk.py
Misc/NEWS.d/next/Library/2017-08-08-14-59-26.bpo-31135.9q1QdB.rst [new file with mode: 0644]

index 11254391c0f5f21a932c15b4fe67a3cb3598f4c8..77c93b12ae753b461375bcd379daed6c71e58909 100644 (file)
@@ -1521,7 +1521,9 @@ class LabeledScale(Frame, object):
             pass
         else:
             del self._variable
-            Frame.destroy(self)
+        Frame.destroy(self)
+        self.label = None
+        self.scale = None
 
 
     def _adjust(self, *args):
@@ -1620,5 +1622,8 @@ class OptionMenu(Menubutton):
 
     def destroy(self):
         """Destroy this widget and its associated variable."""
-        del self._variable
+        try:
+            del self._variable
+        except AttributeError:
+            pass
         Menubutton.destroy(self)
diff --git a/Misc/NEWS.d/next/Library/2017-08-08-14-59-26.bpo-31135.9q1QdB.rst b/Misc/NEWS.d/next/Library/2017-08-08-14-59-26.bpo-31135.9q1QdB.rst
new file mode 100644 (file)
index 0000000..4d89633
--- /dev/null
@@ -0,0 +1,4 @@
+ttk: Fix LabeledScale and OptionMenu destroy() method. 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.