I wrote a simple Python extension function in C that just reads a Numpy array and it crashes.
static PyObject *test(PyObject *self, PyObject *args)
{
PyArrayObject *array = NULL;
if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &array)) // Crash
return NULL;
return Py_BuildValue("d", 0);
}
Here is how it is called:
l = np.array([1,2,3,1,2,2,1,3])
print("%d" % extension.test(l))
What's wrong with my code?