[Python-Dev] RE: More fun with Python shutdown
Bernhard Herzog
bh at intevation.de
Tue Nov 11 12:22:00 EST 2003
"Tim Peters" <tim at zope.com> writes:
>> When trying to debug this in Zope 3, I similarly noticed that prints
>> in the weakref callback produced no output.
>
> I'm not sure this one's worth pursuing. Your problem occurred during the
> second call to gc in finalization, and the sys module has been gutted by
> that point. In particular, sys.stdout has been cleared, so a print
> statement can't work then. The only mystery to me wrt this is why it didn't
> raise an exception, like the
>
>>> Exception exceptions.AttributeError: "'NoneType' object has no attribute
>>> 'write'" in <function <lambda> at 0x006B6C70> ignored
>
> raised when calling that little program with "sys" instead of "__builtin__".
Perhaps because sys.stderr has also been cleared?
Python 2.3.2 (#2, Oct 6 2003, 19:39:48)
[GCC 3.3.2 20030908 (Debian prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class C(object):
... def __del__(self):
... print "__del__"
...
>>> import sys
>>> sys.stdout = None
>>> c = C()
>>> del c
Exception exceptions.AttributeError: "'NoneType' object has no attribute 'write'" in <bound method C.__del__ of <__main__.C object at 0x30074fb0>> ignored
>>> sys.stderr = None
>>> c = C()
>>> del c
>>>
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
Thuban http://thuban.intevation.org/
More information about the Python-Dev
mailing list