@@ -2167,7 +2167,6 @@ PyArray_Zero(PyArrayObject *arr)
21672167{
21682168 char * zeroval ;
21692169 int ret , storeflags ;
2170- static PyObject * zero_obj = NULL ;
21712170
21722171 if (_check_object_rec (PyArray_DESCR (arr )) < 0 ) {
21732172 return NULL ;
@@ -2178,25 +2177,19 @@ PyArray_Zero(PyArrayObject *arr)
21782177 return NULL ;
21792178 }
21802179
2181- if (zero_obj == NULL ) {
2182- zero_obj = PyLong_FromLong ((long ) 0 );
2183- if (zero_obj == NULL ) {
2184- return NULL ;
2185- }
2186- }
21872180 if (PyArray_ISOBJECT (arr )) {
21882181 /* XXX this is dangerous, the caller probably is not
21892182 aware that zeroval is actually a static PyObject*
21902183 In the best case they will only use it as-is, but
21912184 if they simply memcpy it into a ndarray without using
21922185 setitem(), refcount errors will occur
21932186 */
2194- memcpy (zeroval , & zero_obj , sizeof (PyObject * ));
2187+ memcpy (zeroval , & npy_ma_global_data -> zero_obj , sizeof (PyObject * ));
21952188 return zeroval ;
21962189 }
21972190 storeflags = PyArray_FLAGS (arr );
21982191 PyArray_ENABLEFLAGS (arr , NPY_ARRAY_BEHAVED );
2199- ret = PyArray_SETITEM (arr , zeroval , zero_obj );
2192+ ret = PyArray_SETITEM (arr , zeroval , npy_ma_global_data -> zero_obj );
22002193 ((PyArrayObject_fields * )arr )-> flags = storeflags ;
22012194 if (ret < 0 ) {
22022195 PyDataMem_FREE (zeroval );
@@ -2213,7 +2206,6 @@ PyArray_One(PyArrayObject *arr)
22132206{
22142207 char * oneval ;
22152208 int ret , storeflags ;
2216- static PyObject * one_obj = NULL ;
22172209
22182210 if (_check_object_rec (PyArray_DESCR (arr )) < 0 ) {
22192211 return NULL ;
@@ -2224,26 +2216,20 @@ PyArray_One(PyArrayObject *arr)
22242216 return NULL ;
22252217 }
22262218
2227- if (one_obj == NULL ) {
2228- one_obj = PyLong_FromLong ((long ) 1 );
2229- if (one_obj == NULL ) {
2230- return NULL ;
2231- }
2232- }
22332219 if (PyArray_ISOBJECT (arr )) {
22342220 /* XXX this is dangerous, the caller probably is not
22352221 aware that oneval is actually a static PyObject*
22362222 In the best case they will only use it as-is, but
22372223 if they simply memcpy it into a ndarray without using
22382224 setitem(), refcount errors will occur
22392225 */
2240- memcpy (oneval , & one_obj , sizeof (PyObject * ));
2226+ memcpy (oneval , & npy_ma_global_data -> one_obj , sizeof (PyObject * ));
22412227 return oneval ;
22422228 }
22432229
22442230 storeflags = PyArray_FLAGS (arr );
22452231 PyArray_ENABLEFLAGS (arr , NPY_ARRAY_BEHAVED );
2246- ret = PyArray_SETITEM (arr , oneval , one_obj );
2232+ ret = PyArray_SETITEM (arr , oneval , npy_ma_global_data -> one_obj );
22472233 ((PyArrayObject_fields * )arr )-> flags = storeflags ;
22482234 if (ret < 0 ) {
22492235 PyDataMem_FREE (oneval );
0 commit comments