[Cython] (bug?) "cdef public" and Python attribute access
David Warde-Farley
wardefar at iro.umontreal.ca
Tue Mar 20 06:44:31 CET 2012
All of this refers to Cython 0.15.1:
I have a "cdef public void" function which takes several ndarrays, that segfaults when I call it from other C code. Inside I use the ".size" attribute, triggering a PyObject_GetAttr, which segfaults. Running in gdb and looking at the generated C code, I see it is because __pyx_n_s__size is NULL, presumably owing to __Pyx_InitStrings() never being called.
Am I to presume this is intended behaviour? i.e. code that generates Python C API (or more specifically GetAttr) calls simply doesn't work/isn't intended to work from "public" functions called from C code? I don't see mention of it in the documentation, so it's kind of a nasty surprise :) (The "api" keyword mentions the import_modulename() business but no signature for that is generated in my header file.)
In this case I can work around it by multiplying the elements of array.shape.
Thanks,
David
More information about the cython-devel
mailing list