summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Schuppenies <okkotonushi@googlemail.com>2008-08-10 11:01:53 (GMT)
committerRobert Schuppenies <okkotonushi@googlemail.com>2008-08-10 11:01:53 (GMT)
commit14646337bff978f5eba7f2add21ffbe89e894c7c (patch)
tree57d4eaa6c351788467ba2cb2e4556b03b12f998a
parent9fc5631be6bb192db6cd5bd9b4305ab801ca3092 (diff)
downloadcpython-14646337bff978f5eba7f2add21ffbe89e894c7c.zip
cpython-14646337bff978f5eba7f2add21ffbe89e894c7c.tar.gz
cpython-14646337bff978f5eba7f2add21ffbe89e894c7c.tar.bz2
Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
menu entries were not deleted.
-rw-r--r--Lib/lib-tk/Tkinter.py10
-rw-r--r--Misc/NEWS3
2 files changed, 13 insertions, 0 deletions
diff --git a/Lib/lib-tk/Tkinter.py b/Lib/lib-tk/Tkinter.py
index 7b116d9..00ee2c8 100644
--- a/Lib/lib-tk/Tkinter.py
+++ b/Lib/lib-tk/Tkinter.py
@@ -2659,7 +2659,17 @@ class Menu(Widget):
self.insert(index, 'separator', cnf or kw)
def delete(self, index1, index2=None):
"""Delete menu items between INDEX1 and INDEX2 (not included)."""
+ if index2 is None:
+ index2 = index1
+ cmds = []
+ for i in range(self.index(index1), self.index(index2)+1):
+ if 'command' in self.entryconfig(i):
+ c = str(self.entrycget(i, 'command'))
+ if c in self._tclCommands:
+ cmds.append(c)
self.tk.call(self._w, 'delete', index1, index2)
+ for c in cmds:
+ self.deletecommand(c)
def entrycget(self, index, option):
"""Return the resource value of an menu item for OPTION at INDEX."""
return self.tk.call(self._w, 'entrycget', index, '-' + option)
diff --git a/Misc/NEWS b/Misc/NEWS
index a2669c6..a197efc 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -41,6 +41,9 @@ Core and Builtins
Library
-------
+- Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
+ menu entries were not deleted.
+
- Copied the implementation of reduce() to _functools.reduce() to have a
version that did not raise a DeprecationWarning under -3.