In article <[EMAIL PROTECTED]>, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Russell E. Owen wrote: > >> Having looked at it again, it is familiar. I copied it when I wrote my >> own code. I avoided using at the time both because the initial >> underscore suggested it was a private method and because it introduces >> an extra function call. >> >> _register has the same weakness that my code had when I used id(func) -- >> it uses the id of the function to generate the unique tk function name, >> but it keeps no reference to that function. >> >> Either Tkinter is clever about keeping a reference to each callable >> around, or else it has the same bug I was seeing and it just doesn't >> show up often enough to have been caught. I should take some time and >> look into that. > >of course it keeps a reference to it; how else do you expect >the Tcl command to find the right PyObjects? Right. Of course. I started out emulating the code for _register but over time made various incremental changes. Eventually I messed up and started taking the id of the wrong thing. I was able to fix that and all is well -- without having to use the mysterious hash function. I also now keep a reference to the tk function name so I can properly delete it when finished. That eliminates a small memory leak. Thanks for all your help. -- Russell -- http://mail.python.org/mailman/listinfo/python-list