From: Robert K. <rob...@gm...> - 2006-06-16 16:45:36
|
Glen W. Mabey wrote: > That is, when I run: > import DFALG > DFALG.bsvmdf( 3 ) > after compiling the below code, it always segfaults, regardless of the > type of the argument given. Just as a sanity check (it's been a little > while since I have written an extension module for Python) I changed the > line containing PyArray_Check() to one that calls PyInt_Check(), which > does perform exactly how I would expect it to. > > Is there something I'm missing? Yes! > #include <Python.h> > #include <arrayobject.h> This should be "numpy/arrayobject.h" for consistency with every other numpy-using extension. > PyMODINIT_FUNC > initDFALG(void) > { > (void) Py_InitModule("DFALG", DFALGMethods); > } You need to call import_array() in this function. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco |