Hi,

I committed a cpyext+numpy failing test in a3c3b75a7f2b.
In short, the following fails:

    if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &obj))
        return NULL;

The problem is that PyArray_Type is currently defined in ndarrayobject.c but never initialized:

    PyTypeObject PyArray_Type;

not a suprise that we get a segfault when we try to use it.

However, I'm not sure about what is the best way to fix it, so I ask the cpyext wizards :)

I think that at the end what we want is an object for which &PyArray_Type is equal to the PyObject* that we get when we pass _numpypy.multiarray.ndarray to C.

One possibility is to run the following code in some initialization function:

    static PyObject* _PyArray_Type;
    #define PyArray_Type (*_PyArray_Type)

    PyObject* np = PyImport_ImportModule("numpy");
    if (!np)
        return;

    _PyArray_Type = PyObject_GetAttrString(np, "ndarray");
    if (!My_PyArray_Type)
        return;


I'm sure there is a better way to do this. However, I tried to play with the cpyext source for a while and didn't manage to find it. Any suggestion?

ciao,
Anto
_______________________________________________
pypy-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to