[Python-checkins] r65622 - in python/trunk: Lib/lib-tk/Tkinter.py Misc/NEWS

robert.schuppenies python-checkins at python.org
Sun Aug 10 13:01:54 CEST 2008


Author: robert.schuppenies
Date: Sun Aug 10 13:01:53 2008
New Revision: 65622

Log:
Issue #1342811: Fix leak in Tkinter.Menu.delete. Commands associated to
menu entries were not deleted.



Modified:
   python/trunk/Lib/lib-tk/Tkinter.py
   python/trunk/Misc/NEWS

Modified: python/trunk/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/trunk/Lib/lib-tk/Tkinter.py	(original)
+++ python/trunk/Lib/lib-tk/Tkinter.py	Sun Aug 10 13:01:53 2008
@@ -2659,7 +2659,17 @@
         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)

Modified: python/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS	(original)
+++ python/trunk/Misc/NEWS	Sun Aug 10 13:01:53 2008
@@ -41,6 +41,9 @@
 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.
 


More information about the Python-checkins mailing list