Issue 1513802: del: Type is cleared before instances (original) (raw)

Created on 2006-06-28 07:41 by arunarunarun, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
test.py arunarunarun,2006-06-28 07:43 Script to demonstrate the problem
Messages (4)
msg28960 - (view) Author: Arun (arunarunarun) Date: 2006-06-28 07:41
[Python n00b alert] I'm trying this little script, and I see an exception like: Exception exceptions.AttributeError: "'NoneType' object has no attribute 'refcount'" in <bound method Shape.__del__ of Line> ignored If I change the variable name 's1' to something like 's4', I don't see this exception. Also, if I manually delete the object before the script ends, the exception does not occur. Seems that class Shape is destroyed before all it's objects are destroyed. Is this acceptable?
msg28961 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2006-06-29 21:29
Logged In: YES user_id=4771 It is not the type object that is cleared, it is the global names of the module. They are replaced with None when the interpreter shuts down, which is why the expression 'Shape.refcount' find None under the name 'Shape'. It's an obscure leftover for historical reasons. I'm not sure why the problem somes bites and sometimes not. A workaround is to avoid reading globals from __del__() methods; e.g. use self.__class__.refcount instead of Shape.refcount... (This of course doesn't excuse the fact that this is a long-standing bug.)
msg84514 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-03-30 05:56
Confirmed on trunk and py3k. Has this passed the the won't-fix threshold?
msg84539 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-03-30 12:15
No, but I believe this is addressed in some other bugs like #812369.
History
Date User Action Args
2022-04-11 14:56:18 admin set github: 43567
2009-03-30 12:15:00 benjamin.peterson set status: open -> closednosy: + benjamin.petersonmessages: + resolution: duplicate
2009-03-30 05:56:52 ajaksu2 set versions: + Python 2.6, Python 3.0, - Python 2.4nosy: + ajaksu2messages: + type: behaviorstage: test needed
2006-06-28 07:41:12 arunarunarun create