Muppy tutorial

7 views
Skip to first unread message

Jean

unread,
Nov 29, 2008, 2:59:02 PM11/29/08
to pympler-dev
Robert,

In the muppy tutorial near the end, there is this function:

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 self.entryconfig(i).has_key('command'):
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)

It seems that this should be:
....
if index2 is None:
index2 = index1 + 1 # index1 only
cmds = []
for i in range(self.index(index1), self.index(index2)): #
exclude index2
....

since index2 should not be included. However, I did not test this.

Also, does that memory leak still exits in IDLE?

/Jean

Robert Schuppenies

unread,
Dec 2, 2008, 3:29:33 PM12/2/08
to pympl...@googlegroups.com
The code shown in tutorial.rst is not the final one. There was some
discussion and the patch had to modified a bit. I've updated the
docs to reflect the final patch.
IIRC the index2 handling of the underlying tcl implementation was
somewhat confusing which let to this. But I am not sure, though. The
final patch was reviewed by 3 people, so it should be correct.

By now, this memory leak is fixed in Python 2.5 and after.


cheers,
robert

Reply all
Reply to author
Forward
0 new messages