[SciPy-dev] Core dump in PyArray_Return

Sasha ndarray at mac.com
Sun Jan 8 17:20:02 CST 2006


I cannot reproduce the problem with a small example, but the following
change fixes it:

Index: numpy/core/src/arrayobject.c
===================================================================
--- numpy/core/src/arrayobject.c        (revision 1855)
+++ numpy/core/src/arrayobject.c        (working copy)
@@ -915,8 +915,7 @@
                 Py_XDECREF(mp);
                 return NULL;
         }
-
-       if (mp->nd == 0) {
+       if (mp->nd == 0 && !PyArray_IsScalar(mp, Generic)) {
                PyObject *ret;
                ret = PyArray_ToScalar(mp->data, mp);
                Py_DECREF(mp);

Apparently in my program PyArray_Return somehow gets an object that is
already a scalar  and calls PyArray_ToScalar on it.  Is it a
legitimate scenario, or a symptom of a problem elsewhere?  If
PyArray_Return can legitimately receive scalars, maybe the code should
be changed as above. Alternatively PyArray_IsScalar could be modified
to pass scalars unchanged.

-- sasha




More information about the Scipy-dev mailing list