[Matrix-SIG] buglet and fix

Warren B. Focke warren@pfiesteria.gsfc.nasa.gov
Thu, 11 Mar 1999 18:37:24 -0500 (EST)


> >>> from Numeric import array
> >>> a=array((1,2,3))
> >>> del a[2:]
> Segmentation fault

	The fix for this (in array_ass_slice) is copied directly from
array_ass_sub.  I suspect it should go in array_ass_item too.  I couldn't
activate that path from within the interpreter, but an extension module
could call PyObject_DelItem on an array.

Warren Focke

--- arrayobject.c.orig  Wed Mar 10 23:20:43 1999
+++ arrayobject.c       Wed Mar 10 23:12:30 1999
@@ -520,6 +520,11 @@
        int ret;
        PyArrayObject *tmp;
 
+       if (v == NULL) {
+               PyErr_SetString(PyExc_ValueError, "Can't delete array elements.");
+               return -1;
+       }
+
        if ((tmp = (PyArrayObject *)array_slice(self, ilow, ihigh)) == NULL) return -1;  
        ret = PyArray_CopyObject(tmp, v);
        Py_DECREF(tmp);