Title: Menu deletecommand fails if command is already deleted
Type: behavior Stage: resolved
Components: Tkinter Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: gpolo Nosy List: BreamoreBoy, asvetlov, cheryl.sabella, gpolo, gregcouch
Priority: normal Keywords: patch

Created on 2009-06-11 21:09 by gregcouch, last changed 2018-05-04 12:30 by cheryl.sabella. This issue is now closed.

File name Uploaded Description Edit
delcmd.patch gregcouch, 2009-06-11 21:17 revised deletecommand patch
Messages (3)
msg89262 - (view) Author: Greg Couch (gregcouch) Date: 2009-06-11 21:09
Sometime around Python 2.5.4, Menu.delete was changed to delete
associated entry commands (and thus plug a memory leak).  This broke
Pmw.OptionMenu because it already had similar code, so when Menu.delete
was called, the commands were already gone, and a TclError was raised
saying "can't delete Tcl command".

While Pmw could be patched to workaround this bug, it seems strange that
Tkinter.Misc.deletecommand unconditionally deletes commands it knows
nothing about.  All uses of deletecommand in Tkinter refer to commands
that were Tkinter.Misc._register'ed, so they should appear in the
widget._tclCommands list.  So the proper solution is to only delete
commands that are still registered with the widget.

Repeat by:

import Pmw
om = Pmw.OptionMenu()
om.setitems(['a', 'b'])
msg220772 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-06-16 21:44
I've tried to reproduce this on Windows 7 with Python 3.4.1 and failed.  Would somebody else please give it a go.
msg316168 - (view) Author: Cheryl Sabella (cheryl.sabella) * (Python committer) Date: 2018-05-04 12:30
I installed the latest version of pmw on Ubuntu 14.04 and did not receive any errors using the supplied test snippet.  It appears that pmw added a patch to the code to only delete the commands when used with Python versions before 2.5.4 so that this bug would not be triggered.

This could be revisited if someone else runs into an issue with deletecommand, but closing for now as out of date.
Date User Action Args
2018-05-04 12:30:27cheryl.sabellasetstatus: open -> closed

nosy: + cheryl.sabella
messages: + msg316168

resolution: out of date
stage: patch review -> resolved
2014-06-16 21:44:04BreamoreBoysetnosy: + BreamoreBoy
messages: + msg220772
2012-03-22 22:38:41asvetlovsetnosy: + asvetlov
2010-07-11 13:25:53BreamoreBoysetassignee: gpolo
versions: - Python 2.6
nosy: + gpolo
2010-02-09 16:49:21brian.curtinsetpriority: normal
stage: patch review
type: crash -> behavior
versions: + Python 3.2, - Python 2.5, Python 3.0
2009-06-11 21:17:33gregcouchsetfiles: - delcmd.patch
2009-06-11 21:17:26gregcouchsetfiles: + delcmd.patch
2009-06-11 21:09:39gregcouchcreate