Bug or feature?

John Wezel (wezel@dial.eunet.ch)
Mon, 29 Aug 1994 11:27:21 +0200

I am creating a class which uses __init__ and __del__ methods. The __init__ method has a try/except construct. The problem is, whenever the except clause in __init__ is executed, then the __del__ method is not called upon destruction of the object. Is this a bug or a feature? The functionality is the same on the 32-bit DOS version 1.0.2 as well as the QNX version 1.0.0 I built from the sources. If this is a bug, here is a module which shows the problem:

class test:
def __init__ (self, arg):
try:
self.attr = 1 / arg
print 'Success'
except:
print 'Exception'

def __del__ (self):
print 'Delete'

A test for this might look like:

Python 1.0.2 (May 13 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> import test
>>> a=test.test(1)
Success
>>> del a
Delete
>>> b=test.test(0)
Exception
>>> del b
>>>

________________________________________________________________
John Wezel
wezel@dial.eunet.ch