[C-API] Weird sys.exc_info reference segfault

Jonas H. jonas at lophus.org
Mon Oct 4 23:30:58 CEST 2010

On 10/04/2010 10:46 AM, Jonas H. wrote:
> On 10/03/2010 11:52 PM, Antoine Pitrou wrote:
>> You probably have a problem in your tp_dealloc implementation.
> `tp_dealloc` is NULL...

Alright, `tp_dealloc` must not be NULL because it's called by 
`_Py_Dealloc`.  The C-API tutorial is quite confusing here:

> [...] here's a minimal, but __complete__, module that defines a new type:
> [...]
> static PyTypeObject noddy_NoddyType = {
>     [...]
>     0,                         /*tp_dealloc*/
>     [...]
> };

So I thought "complete" meant "it works". Actually, DECREFing that an 
object of *that* type does not work, it crashes because of the NULL 
`tp_dealloc` function pointer that is called in `_Py_Dealloc`.


More information about the Python-list mailing list