diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-12-15 19:15:01 -0600 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-12-15 19:15:01 -0600 |
| commit | d1a3ce551944fa0f2b1a10e290a5f8a3283982ba (patch) | |
| tree | 87894995e1eb7fa0709f2dcb2c331f550c134faa | |
| parent | 4d16baca2494718e16016375b04e82cfe8de1b81 (diff) | |
| download | numpy-d1a3ce551944fa0f2b1a10e290a5f8a3283982ba.tar.gz | |
MAINT: Use `PyArray_NBYTES_ALLOCATED` for data setting
| -rw-r--r-- | numpy/core/src/multiarray/getset.c | 10 |
1 files changed, 1 insertions, 9 deletions
diff --git a/numpy/core/src/multiarray/getset.c b/numpy/core/src/multiarray/getset.c index e81ca2947..ac2e997f4 100644 --- a/numpy/core/src/multiarray/getset.c +++ b/numpy/core/src/multiarray/getset.c @@ -384,15 +384,7 @@ array_data_set(PyArrayObject *self, PyObject *op, void *NPY_UNUSED(ignored)) } if (PyArray_FLAGS(self) & NPY_ARRAY_OWNDATA) { PyArray_XDECREF(self); - size_t nbytes = PyArray_NBYTES(self); - /* - * Allocation will never be 0, see comment in ctors.c - * line 820 - */ - if (nbytes == 0) { - PyArray_Descr *dtype = PyArray_DESCR(self); - nbytes = dtype->elsize ? dtype->elsize : 1; - } + size_t nbytes = PyArray_NBYTES_ALLOCATED(self); PyObject *handler = PyArray_HANDLER(self); if (handler == NULL) { /* This can happen if someone arbitrarily sets NPY_ARRAY_OWNDATA */ |
