[Pyrex] NoneType object is not callable in dealloc
AKX
theakx at gmail.com
Thu Sep 29 19:57:51 CEST 2005
Hiya,
I'm making a rather large wrapper for a rather large library, but now
I've reached an impasse...
When a program exits with an AlFont instance in memory, it crashes
(Win32), emitting "Exception exceptions.TypeError: "'NoneType' object
is not callable" in <_pyalleg.AlFont object at 0x009EC060> ignored".
Through print debugging (arcane art, I say), I've found out it crashes
in the debug() line. Other classes built similarly do not crash in a
similar situation.
The responsible code follows (and the generated C is a bit abridged
and formatted).
Does anyone have any pointers on how to fix this, or is it a Pyrex
bug? (Always blame the tool developers... just kidding, Pyrex rocks.)
Thanks in advance,
AKX
--------------------------------------------------------------------------------
== _pyalleg.pyx snippet ==
cdef class AlFont:
cdef ALFONT_FONT *f
# SNIP
def __dealloc__(self):
if self.f!=NULL: # <-- line 825
debug("Deallocating AlFont "+str(self))
alfont_destroy_font(self.f) # void ... (ALFONT_FONT *)
self.f=NULL
# SNIP
== _pyalleg.c snippet ==
static PyObject *__pyx_k99p; // "Deallocating AlFont "
static PyObject *__pyx_k100p; // "AlFont already deallocated: "
static void __pyx_f_8_pyalleg_6AlFont___dealloc__(PyObject *__pyx_v_self)
{
int __pyx_1;
PyObject *__pyx_2,*__pyx_3,*__pyx_4,*__pyx_5;
Py_INCREF(__pyx_v_self);
/* "_pyalleg.pyx":825 */
__pyx_1 = (((struct __pyx_obj_8_pyalleg_AlFont *)__pyx_v_self)->f != 0);
if (__pyx_1) {
/* "_pyalleg.pyx":826 */
__pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_debug);
if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
__pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_str);
if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
__pyx_4 = PyTuple_New(1);
if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
Py_INCREF(__pyx_v_self);
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_v_self);
__pyx_5 = PyObject_CallObject(__pyx_3, __pyx_4);
if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
Py_DECREF(__pyx_3); __pyx_3 = 0;
Py_DECREF(__pyx_4); __pyx_4 = 0;
__pyx_3 = PyNumber_Add(__pyx_k99p, __pyx_5);
if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
Py_DECREF(__pyx_5); __pyx_5 = 0;
__pyx_4 = PyTuple_New(1);
if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3);
__pyx_3 = 0;
__pyx_5 = PyObject_CallObject(__pyx_2, __pyx_4);
if (!__pyx_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826;
goto __pyx_L1;}
Py_DECREF(__pyx_2,__pyx_4,__pyx_5);
/* "_pyalleg.pyx":827 */
alfont_destroy_font(((struct __pyx_obj_8_pyalleg_AlFont *)__pyx_v_self)->f);
/* "_pyalleg.pyx":828 */
((struct __pyx_obj_8_pyalleg_AlFont *)__pyx_v_self)->f = 0;
}
goto __pyx_L0;
__pyx_L1:;
Py_XDECREF(__pyx_2,__pyx_3,__pyx_4,__pyx_5);
__Pyx_AddTraceback("_pyalleg.AlFont.__dealloc__");
__pyx_L0:;
Py_DECREF(__pyx_v_self);
}
More information about the Pyrex
mailing list