fault and core dump. Frankly it's still mysterious, but at the moment the problem seems to be that I have passed in a list of tuples, rather than a list of PyArrayObjects. I don't expect this to work, but when I put a :
site = PyList_GetItem(spam_list, index);
if (! PyArray_Check(spam)) result = 0;
I shouldn't get a crash!! (and it does crash at this line, as near as I can tell)
If spam is NULL, then the check will crash. If it is anything but a pointer to a Python object, there's a good chance that it might crash. PyArray_Check just tells you if a given Python object is of type "array".
A look at the value of "spam" with a debugger should tell you what's going on.
which goes away if I typecast it:
spam = (PyArrayObject *) PyList_GetItem(spam_list, index);
Should I be doing this, and should PyArray_Check(spam) work either way?
It works either way, but I am not sure that you are supposed to rely on that. I prefer to use a cast to array objects only *after* verifying that I have an array object, if only for clarity.