8000 BUG: Clean up reference handling in `ufunc.at` a little. · mattip/numpy@f064552 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit f064552

Browse files
committed
BUG: Clean up reference handling in ufunc.at a little.
1 parent 3802b16 commit f064552

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

numpy/core/src/umath/ufunc_object.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5887,6 +5887,7 @@ static inline PyArrayObject *
58875887
new_array_op(PyArrayObject *op_array, char *data)
58885888
{
58895889
npy_intp dims[1] = {1};
5890+
Py_INCREF(PyArray_DESCR(op_array)); /* NewFromDescr steals a reference */
58905891
PyObject *r = PyArray_NewFromDescr(&PyArray_Type, PyArray_DESCR(op_array),
58915892
1, dims, NULL, data,
58925893
NPY_ARRAY_WRITEABLE, NULL);
@@ -6033,14 +6034,11 @@ ufunc_at__slow_iter(PyUFuncObject *ufunc, NPY_ARRAYMETHOD_FLAGS flags,
60336034
}
60346035
array_operands[0] = new_array_op(op1_array, iter->dataptr);
60356036
if (iter2 != NULL) {
6036-
Py_INCREF(PyArray_DESCR(op2_array));
60376037
array_operands[1] = new_array_op(op2_array, PyArray_ITER_DATA(iter2));
6038-
Py_INCREF(PyArray_DESCR(op1_array));
60396038
array_operands[2] = new_array_op(op1_array, iter->dataptr);
60406039
nop = 3;
60416040
}
60426041
else {
6043-
Py_INCREF(PyArray_DESCR(op1_array));
60446042
array_operands[1] = new_array_op(op1_array, iter->dataptr);
60456043
array_operands[2] = NULL;
60466044
nop = 2;
@@ -6284,8 +6282,6 @@ ufunc_at(PyUFuncObject *ufunc, PyObject *args)
62846282
PyArrayMethodObject *ufuncimpl = NULL;
62856283
{
62866284
/* Do all the dtype handling and find the correct ufuncimpl */
6287-
Py_INCREF(PyArray_DESCR(op1_array));
6288-
62896285

62906286
PyArrayObject *tmp_operands[3] = {NULL, NULL, NULL};
62916287
PyArray_DTypeMeta *signature[3] = {NULL, NULL, NULL};

0 commit comments

Comments
 (0)
0