Robert Bradshaw wrote: > On Feb 24, 2009, at 10:26 AM, Stefan Behnel wrote: >>>>> In any case, the only way to write safe code is to avoid the >>>>> usage of >>>>> module-level globals in __del__() and __dealloc__() methods... >>>> Which is a rare thing anyway. Most of the time, you'd just call >>>> some kind of free() function and be done. > > A more common case is that is uses an interned string (e.g. to lookup > something in a dictionary).
Could we disable things like this at least for __dealloc__() methods? I.e. is there a reason __dealloc__() should not have nogil restrictions? I just read up on the official specification of __del__(). http://docs.python.org/reference/datamodel.html#basic-customization The specification contains a clear warning that module globals may no longer exist when __del__() is called on an object. IMHO, that makes a closure for __del__() less of a requirement, although it makes more sense in the context of Cython than in Python. It would definitely help to keep users from writing innocently looking code that crashes (such as "1+1"). Stefan _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
