Issue1513802
Created on 2006-06-28 07:41 by arunarunarun, last changed 2009-03-30 12:15 by benjamin.peterson.
| File name |
Uploaded |
Description |
Edit |
Remove |
|
test.py
|
arunarunarun,
2006-06-28 07:43
|
Script to demonstrate the problem |
|
|
|
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) |
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) |
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) |
Date: 2009-03-30 12:15 |
|
No, but I believe this is addressed in some other bugs like #812369.
|
|
| Date |
User |
Action |
Args |
| 2009-03-30 12:15:00 | benjamin.peterson | set | status: open -> closed
nosy:
+ benjamin.peterson messages:
+ msg84539
resolution: duplicate |
| 2009-03-30 05:56:52 | ajaksu2 | set | versions:
+ Python 2.6, Python 3.0, - Python 2.4 nosy:
+ ajaksu2
messages:
+ msg84514
type: behavior stage: test needed |
| 2006-06-28 07:41:12 | arunarunarun | create | |
|