Issue 541883: delattr() causes python to segfault (original) (raw)

delattr() causes python to segfault with builtins types

First a normal case to see what it should do :

Python 2.2.1c2 (#1, Apr 3 2002, 14:02:46) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

a = 5 delattr(a, "class") Traceback (most recent call last): File "", line 1, in ? TypeError: 'int' object has only read-only attributes (del .class)

Then the faulty case :

Python 2.2.1c2 (#1, Apr 3 2002, 14:02:46) [GCC 2.95.4 20011002 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information.

a = 5 a.class <type 'int'> delattr(a, "class") Segmentation fault.

I don't know why, but if i access to a.class before deleting it, it cause this error. The same occurs if i use another base type such as a string or a list. I haven't tried other attributes than class, but it may worth trying.