diff options
| author | Sebastian Berg <sebastian@sipsolutions.net> | 2021-06-16 16:13:11 -0500 |
|---|---|---|
| committer | Sebastian Berg <sebastian@sipsolutions.net> | 2021-06-16 18:47:24 -0500 |
| commit | 28dceccde97af2554dd151d8ea879997f171c08f (patch) | |
| tree | a579bde62f75d3ddc0f44dc5340c7ecc7e6a49a3 | |
| parent | b5cc1f80c6747e6c19adeaf241d2d471d2b71cb7 (diff) | |
| download | numpy-28dceccde97af2554dd151d8ea879997f171c08f.tar.gz | |
MAINT: Some tiny fixes and style changes in `ufunc_object.c`
Technically, the index setref fixes reference count issues on
failure. Setting it to NULL isn't really necessary, but means
that `goto fail` could be used later also.
| -rw-r--r-- | numpy/core/src/umath/ufunc_object.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/numpy/core/src/umath/ufunc_object.c b/numpy/core/src/umath/ufunc_object.c index 0644a28c0..1f6315a1f 100644 --- a/numpy/core/src/umath/ufunc_object.c +++ b/numpy/core/src/umath/ufunc_object.c @@ -3186,7 +3186,7 @@ PyUFunc_Accumulate(PyUFuncObject *ufunc, PyArrayObject *arr, PyArrayObject *out, int idim, ndim, otype_final; int needs_api, need_outer_iterator; - NpyIter *iter = NULL, *iter_inner = NULL; + NpyIter *iter = NULL; /* The selected inner loop */ PyUFuncGenericFunction innerloop = NULL; @@ -3512,9 +3512,6 @@ finish: if (!NpyIter_Deallocate(iter)) { res = -1; } - if (!NpyIter_Deallocate(iter_inner)) { - res = -1; - } if (res < 0) { Py_DECREF(out); return NULL; @@ -3527,7 +3524,6 @@ fail: Py_XDECREF(op_dtypes[0]); NpyIter_Deallocate(iter); - NpyIter_Deallocate(iter_inner); return NULL; } @@ -4263,8 +4259,8 @@ PyUFunc_GenericReduction(PyUFuncObject *ufunc, */ int typenum = PyArray_TYPE(mp); if ((PyTypeNum_ISBOOL(typenum) || PyTypeNum_ISINTEGER(typenum)) - && ((strcmp(ufunc->name,"add") == 0) - || (strcmp(ufunc->name,"multiply") == 0))) { + && ((strcmp(ufunc->name, "add") == 0) + || (strcmp(ufunc->name, "multiply") == 0))) { if (PyTypeNum_ISBOOL(typenum)) { typenum = NPY_LONG; } @@ -4310,9 +4306,9 @@ PyUFunc_GenericReduction(PyUFuncObject *ufunc, "reduceat does not allow multiple axes"); goto fail; } - ret = (PyArrayObject *)PyUFunc_Reduceat(ufunc, mp, indices, out, - axes[0], otype->type_num); - Py_DECREF(indices); + ret = (PyArrayObject *)PyUFunc_Reduceat(ufunc, + mp, indices, out, axes[0], otype->type_num); + Py_SETREF(indices, NULL); break; } Py_DECREF(mp); @@ -4354,6 +4350,7 @@ fail: Py_XDECREF(otype); Py_XDECREF(mp); Py_XDECREF(wheremask); + Py_XDECREF(indices); Py_XDECREF(full_args.in); Py_XDECREF(full_args.out); return NULL; |
