__del__ may cause that objects are not deleted from memory (unless it's manually taken care of :P):
http://docs.python.org/reference/datamodel.html#object.__del__
http://docs.python.org/library/gc.html#gc.garbage
Edit: Also, it may be possible that __del__ is never called because of this problem:
http://bugs.python.org/issue9072
/Edit
So I suggest that the __del__ in decorator.py is actually removed and that the events are unregistered else where :P
Issues with __del__
This doesn't seem as big a deal right now as you are trying to lead us to believe. If the object actually isn't removed from memory, that really isn't the fault of using __del__ to unregister for an event. If we don't call __del__, the object will still remain in memory anyway, and the event will not be unregistered. So, what do we accomplish in this regard by changing our method of unregistering for the event?
I can see that if an error occurs during __del__ (which is highly unlikely), there would be the issue of the event not being unregistered. However, the only things "we" do in __del__ is unregister for the event and then re-call __del__ (this change hasn't been pushed yet).
Satoon
I can see that if an error occurs during __del__ (which is highly unlikely), there would be the issue of the event not being unregistered. However, the only things "we" do in __del__ is unregister for the event and then re-call __del__ (this change hasn't been pushed yet).
Satoon
The problem with using __del__ (and not just when using the decorator) is that it may lead to unexpected memory leaks. As such, it should be avoided to use, just because it seems like something dangerous to use (and so far I've been able to find a way to get things working properly without using the __del__ method even if it requires some extra work).
This is probably also a candiate for the 'SP design docs' (in addition to the PEP8 stuff).
On a side note that recent change actually contains an error since object does not have a __del__ method (no python class has a __del__ method by default AFAIK):
This is probably also a candiate for the 'SP design docs' (in addition to the PEP8 stuff).
On a side note that recent change actually contains an error since object does not have a __del__ method (no python class has a __del__ method by default AFAIK):
Code: Select all
>>> object.__del__
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
object.__del__
AttributeError: type object 'object' has no attribute '__del__'
>>> class a(object):
def __del__(self):
super(a, self).__del__()
>>> b = a()
>>> del b
Exception AttributeError: "'super' object has no attribute '__del__'" in <bound method a.__del__ of <__main__.a object at 0x02AE0770>> ignored
Who is online
Users browsing this forum: No registered users and 37 guests