From: Konrad H. <hi...@cn...> - 2000-10-19 17:25:34
|
> 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; ^^^^ Not "site"? > 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. Konrad. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hi...@cn... Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- |