@@ -44,6 +44,11 @@ array_shape_set(PyArrayObject *self, PyObject *val)
4444 int nd ;
4545 PyObject * ret ;
4646
47+ if (val == NULL ) {
48+ PyErr_SetString (PyExc_AttributeError ,
49+ "Cannot delete array shape" );
50+ return -1 ;
51+ }
4752 /* Assumes C-order */
4853 ret = PyArray_Reshape (self , val );
4954 if (ret == NULL ) {
@@ -99,6 +104,11 @@ array_strides_set(PyArrayObject *self, PyObject *obj)
99104 Py_ssize_t buf_len ;
100105 char * buf ;
101106
107+ if (obj == NULL ) {
108+ PyErr_SetString (PyExc_AttributeError ,
109+ "Cannot delete array strides" );
110+ return -1 ;
111+ }
102112 if (!PyArray_IntpConverter (obj , & newstrides ) ||
103113 newstrides .ptr == NULL ) {
104114 PyErr_SetString (PyExc_TypeError , "invalid strides" );
@@ -305,6 +315,11 @@ array_data_set(PyArrayObject *self, PyObject *op)
305315 Py_ssize_t buf_len ;
306316 int writeable = 1 ;
307317
318+ if (op == NULL ) {
319+ PyErr_SetString (PyExc_AttributeError ,
320+ "Cannot delete array data" );
321+ return -1 ;
322+ }
308323 if (PyObject_AsWriteBuffer (op , & buf , & buf_len ) < 0 ) {
309324 writeable = 0 ;
310325 if (PyObject_AsReadBuffer (op , (const void * * )& buf , & buf_len ) < 0 ) {
@@ -401,6 +416,12 @@ array_descr_set(PyArrayObject *self, PyObject *arg)
401416 int index ;
402417 char * msg = "new type not compatible with array." ;
403418
419+ if (arg == NULL ) {
420+ PyErr_SetString (PyExc_AttributeError ,
421+ "Cannot delete array dtype" );
422+ return -1 ;
423+ }
424+
404425 if (!(PyArray_DescrConverter (arg , & newtype )) ||
405426 newtype == NULL ) {
406427 PyErr_SetString (PyExc_TypeError , "invalid data-type for array" );
@@ -665,6 +686,11 @@ array_real_set(PyArrayObject *self, PyObject *val)
665686 PyArrayObject * new ;
666687 int rint ;
667688
689+ if (val == NULL ) {
690+ PyErr_SetString (PyExc_AttributeError ,
691+ "Cannot delete array real part" );
692+ return -1 ;
693+ }
668694 if (PyArray_ISCOMPLEX (self )) {
669695 ret = _get_part (self , 0 );
670696 if (ret == NULL ) {
@@ -722,6 +748,11 @@ array_imag_get(PyArrayObject *self)
722748static int
723749array_imag_set (PyArrayObject * self , PyObject * val )
724750{
751+ if (val == NULL ) {
752+ PyErr_SetString (PyExc_AttributeError ,
753+ "Cannot delete array imaginary part" );
754+ return -1 ;
755+ }
725756 if (PyArray_ISCOMPLEX (self )) {
726757 PyArrayObject * ret ;
727758 PyArrayObject * new ;
@@ -742,8 +773,8 @@ array_imag_set(PyArrayObject *self, PyObject *val)
742773 return rint ;
743774 }
744775 else {
745- PyErr_SetString (PyExc_TypeError , "array does not have " \
746- " imaginary part to set" );
776+ PyErr_SetString (PyExc_TypeError ,
777+ "array does not have imaginary part to set" );
747778 return -1 ;
748779 }
749780}
@@ -764,7 +795,12 @@ array_flat_set(PyArrayObject *self, PyObject *val)
764795 int swap ;
765796 PyArray_CopySwapFunc * copyswap ;
766797
767- typecode = self -> descr ;
798+ if (val == NULL ) {
799+ PyErr_SetString (PyExc_AttributeError ,
800+ "Cannot delete array flat iterator" );
801+ return -1 ;
802+ }
803+ typecode = PyArray_DESCR (self );
768804 Py_INCREF (typecode );
769805 arr = PyArray_FromAny (val , typecode ,
770806 0 , 0 , FORCECAST | FORTRAN_IF (self ), NULL );
0 commit comments