[pypy-issue] [issue1621] CPyExt: PyObject_GetItem() fails on NumPyPy array objects

Amaury Forgeot d'Arc tracker at bugs.pypy.org
Wed Oct 9 19:03:46 CEST 2013


Amaury Forgeot d'Arc <amauryfa at gmail.com> added the comment:

Thanks for the test, but I think it has two caveats:

- space.unwrap() cannot return a number, since the result is some numpy instance. You could use 
space.eq_w(w_result, space.wrap(2)) instead.

- api.PyObject_GetItem() does not try to convert the value to a PyObject* pointer; it only manipulates w_objects, 
so the initial issue is not reproduced here; try to use make_ref() on the result

Or don't use PyObject_GetItem at all: it's not part of the problem!
Only make_ref() of a numpy.int64(2) object.

Maybe something like:

w_obj = space.appexec([], """():
    import numpypy as np
    return np.int64(2)""")
ref = make_ref(space, w_obj)
api.Py_DecRef(ref)

________________________________________
PyPy bug tracker <tracker at bugs.pypy.org>
<https://bugs.pypy.org/issue1621>
________________________________________


More information about the pypy-issue mailing list