diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-07-31 20:49:07 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-07-31 20:49:07 +0000 |
commit | 1385d652ec78cad2191f1abda25567c24201d1d5 (patch) | |
tree | e93e18f08fa9530a553b14f623379e6cbac1e361 /numpy | |
parent | be7266db9d9126d5333b534965c6eb9ced56f0de (diff) | |
download | numpy-1385d652ec78cad2191f1abda25567c24201d1d5.tar.gz |
MAINT: Move variables into deepest relevant scope, for clarity
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/src/multiarray/getset.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c index 2b7d498aa..77d9b8c66 100644 --- a/numpy/core/src/multiarray/getset.c +++ b/numpy/core/src/multiarray/getset.c @@ -437,11 +437,6 @@ static int array_descr_set(PyArrayObject *self, PyObject *arg) { PyArray_Descr *newtype = NULL; - npy_intp newdim; - int axis; - PyObject *safe; - static PyObject *checkfunc = NULL; - if (arg == NULL) { PyErr_SetString(PyExc_AttributeError, @@ -458,6 +453,9 @@ array_descr_set(PyArrayObject *self, PyObject *arg) /* check that we are not reinterpreting memory containing Objects. */ if (_may_have_objects(PyArray_DESCR(self)) || _may_have_objects(newtype)) { + static PyObject *checkfunc = NULL; + PyObject *safe; + npy_cache_import("numpy.core._internal", "_view_is_safe", &checkfunc); if (checkfunc == NULL) { goto fail; @@ -492,6 +490,9 @@ array_descr_set(PyArrayObject *self, PyObject *arg) /* Changing the size of the dtype results in a shape change */ if (newtype->elsize != PyArray_DESCR(self)->elsize) { + int axis; + npy_intp newdim; + /* forbidden cases */ if (PyArray_NDIM(self) == 0) { PyErr_SetString(PyExc_ValueError, |