[issue9756] Crash with custom __getattribute__

Meador Inge report at bugs.python.org
Sun Sep 5 22:36:39 CEST 2010


Meador Inge <meadori at gmail.com> added the comment:

> To fix the segfault, I suppose that we use a more strict validation on 
> the input type. Eg. Use PyUnicode_Check() instead of 
> PyObject_IsInstance()?

Where would the more strict validation take place?  This problem is not unique to Unicode objects:

motherbrain:py3k minge$ ./python.exe 
Python 3.2a2 (py3k:84541, Sep  5 2010, 15:11:19) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> class MyClass(object):
...    def __init__(self):
...       self.pwn = None
...    def __getattribute__(self, name):
...       return getattr(187, name)
... 
[49633 refs]
>>> instance = MyClass()
[49640 refs]
>>> int.bit_length(instance)
Assertion failed: (PyLong_Check(v)), function long_bit_length, file Objects/longobject.c, line 4397.
Abort trap

----------
nosy: +meador.inge

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9756>
_______________________________________


More information about the Python-bugs-list mailing list