super not working in __del__ ?
Christopher J. Bottaro
cjbottaro at alumni.cs.utexas.edu
Wed Feb 16 11:36:38 EST 2005
Fredrik Lundh wrote:
> "Warning: Due to the precarious circumstances under which __del__()
> methods are invoked, exceptions that occur during their execution are
> ignored, and a warning is printed to sys.stderr instead. Also, when
> __del__() is invoked in response to a module being deleted (e.g.,
> when execution of the program is done), other globals referenced by
> the __del__() method may already have been deleted. For this
> reason, __del__() methods should do the absolute minimum needed
> to maintain external invariants."
Jeff Epler wrote:
> * Bugs and caveats: The destruction of modules and objects in
> modules is * done in random order; this may cause destructors
> (__del__() methods) to * fail when they depend on other objects
> (even functions) or modules.
2 Questions...
1) Why does this never happen in C++? Or does it, its just never happened
to me?
2) I can understand random destruction of instantiated objects, but I find
it weird that class definitions (sorry, bad terminology) are destroyed at
the same time. So __del__ can't safely instantiate any classes if its
being called as a result of interpreter shutdown? Boo...
Oh well, thanks for the help...now I know.
More information about the Python-list
mailing list