Pb with __del__ and inheritence

Erwan Adam erwan.adam at cea.fr
Wed Mar 7 05:35:05 EST 2007


Hello all,

Can someone reproduce this bug ... I use :

[adam at is111902 /home/adam/Work/Python]> python
Python 2.4.3 (#2, Sep 18 2006, 21:07:35)
[GCC 4.1.1 20060724 (prerelease) (4.1.1-3mdk)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>>

First test :

[adam at is111902 /home/adam/Work/Python]> cat bug_del.py && echo "------" 
&& python bug_del.py

class XObject(object):

     def __del__(self):
         print "XObject.__del__"
         return

     pass

class A(XObject):

     def __del__(self):
         print "A.__del__"
         XObject.__del__(self)
         return

     pass

a = A()
------
A.__del__
XObject.__del__
[adam at is111902 /home/adam/Work/Python]>

Everything is ok ... now I just replace "a = A()" by "aaa = A()":

[adam at is111902 /home/adam/Work/Python]> cat bug_del.py && echo "------" 
&& python bug_del.py

class XObject(object):

     def __del__(self):
         print "XObject.__del__"
         return

     pass

class A(XObject):

     def __del__(self):
         print "A.__del__"
         XObject.__del__(self)
         return

     pass

aaa = A()
------
A.__del__
Exception exceptions.AttributeError: "'NoneType' object has no attribute 
'__del__'" in <bound method A.__del__ of <__main__.A object at 
0xb7bb124c>> ignored
[adam at is111902 /home/adam/Work/Python]>

!!!


Thanks in advance,

             E.A.



More information about the Python-list mailing list