__del__ igners exception in 2.1?

Tom Good Tom_Good1 at excite.com
Fri Aug 17 14:00:28 EDT 2001


>From the Python 2.1 docs, section on __del__() :

"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."


Vassilis Virvilis <vasvir at iit.demokritos.gr> wrote in message news:<3B7D186A.A3E3FB9E at iit.demokritos.gr>...
> Try the follwoing snippet:
> 
> class bar:
>   def __del__(self):
>     badsnake()
> 
> a=bar()
> del a
> print "It continues"
> 
> it spits:
> Exception exceptions.NameError: "global name 'badsnake' is not defined" in
> <method bar.__del__ of bar instance at 0x80cfa1c> ignored
> It continues
> 
> Why? Shouldn't the exception make python abort?



More information about the Python-list mailing list