[Python-checkins] ttk: fix LabeledScale and OptionMenu destroy() method (#3026)

Victor Stinner webhook-mailer at python.org
Tue Aug 8 13:15:55 EDT 2017


https://github.com/python/cpython/commit/56e162ad5c5d3effe9b4f05d0179e1b6a2a2d9b8
commit: 56e162ad5c5d3effe9b4f05d0179e1b6a2a2d9b8
branch: 2.7
author: Victor Stinner <victor.stinner at gmail.com>
committer: GitHub <noreply at github.com>
date: 2017年08月08日T19:15:52+02:00
summary:
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.
files:
A Misc/NEWS.d/next/Library/2017-08-08-14-59-26.bpo-31135.9q1QdB.rst
M Lib/lib-tk/ttk.py
diff --git a/Lib/lib-tk/ttk.py b/Lib/lib-tk/ttk.py
index 11254391c0f..77c93b12ae7 100644
--- a/Lib/lib-tk/ttk.py
+++ b/Lib/lib-tk/ttk.py
@@ -1521,7 +1521,9 @@ def destroy(self):
 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 @@ def set_menu(self, default=None, *values):
 
 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
index 00000000000..4d89633e126
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2017-08-08-14-59-26.bpo-31135.9q1QdB.rst
@@ -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.


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /