Skip to content

Commit c5e3766

Browse files
committed
MAINt: Rename variables and at least only duplicate cleanup
1 parent 8f03248 commit c5e3766

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

numpy/_core/src/multiarray/multiarraymodule.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,14 +1957,14 @@ array_copyto(PyObject *NPY_UNUSED(ignored),
19571957
if (src == NULL) {
19581958
goto fail;
19591959
}
1960-
PyArray_DTypeMeta *dtype = NPY_DTYPE(PyArray_DESCR(src));
1961-
Py_INCREF(dtype);
1962-
if (npy_mark_tmp_array_if_pyscalar(src_obj, src, &dtype)) {
1960+
PyArray_DTypeMeta *DType = NPY_DTYPE(PyArray_DESCR(src));
1961+
Py_INCREF(DType);
1962+
if (npy_mark_tmp_array_if_pyscalar(src_obj, src, &DType)) {
19631963
/* The user passed a Python scalar */
19641964
PyArray_Descr *descr = npy_find_descr_for_scalar(
1965-
src_obj, PyArray_DESCR(src), dtype,
1965+
src_obj, PyArray_DESCR(src), DType,
19661966
NPY_DTYPE(PyArray_DESCR(dst)));
1967-
Py_DECREF(dtype);
1967+
Py_DECREF(DType);
19681968
if (descr == NULL) {
19691969
goto fail;
19701970
}
@@ -1975,17 +1975,17 @@ array_copyto(PyObject *NPY_UNUSED(ignored),
19751975
}
19761976
}
19771977
else {
1978-
Py_DECREF(dtype);
1978+
Py_DECREF(DType);
19791979
}
19801980

19811981
if (wheremask_in != NULL) {
19821982
/* Get the boolean where mask */
1983-
PyArray_Descr *dtype = PyArray_DescrFromType(NPY_BOOL);
1984-
if (dtype == NULL) {
1983+
PyArray_Descr *descr = PyArray_DescrFromType(NPY_BOOL);
1984+
if (descr == NULL) {
19851985
goto fail;
19861986
}
19871987
wheremask = (PyArrayObject *)PyArray_FromAny(wheremask_in,
1988-
dtype, 0, 0, 0, NULL);
1988+
descr, 0, 0, 0, NULL);
19891989
if (wheremask == NULL) {
19901990
goto fail;
19911991
}

numpy/_core/src/umath/ufunc_object.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,7 @@ reducelike_promote_and_resolve(PyUFuncObject *ufunc,
23562356
if (evil_ndim_mutating_hack) {
23572357
((PyArrayObject_fields *)out)->nd = 0;
23582358
}
2359-
// TODO: Clean up multiple cleanup!
2359+
23602360
if (ufuncimpl == NULL) {
23612361
/* DTypes may currently get filled in fallbacks and XDECREF for error: */
23622362
Py_XDECREF(operation_DTypes[0]);
@@ -2372,18 +2372,15 @@ reducelike_promote_and_resolve(PyUFuncObject *ufunc,
23722372
* casting safety could in principle be set to the default same-kind.
23732373
* (although this should possibly happen through a deprecation)
23742374
*/
2375-
if (resolve_descriptors(3, ufunc, ufuncimpl,
2376-
ops, out_descrs, signature, operation_DTypes, NULL, casting) < 0) {
2377-
/* DTypes may currently get filled in fallbacks and XDECREF for error: */
2378-
Py_XDECREF(operation_DTypes[0]);
2379-
Py_XDECREF(operation_DTypes[1]);
2380-
Py_XDECREF(operation_DTypes[2]);
2381-
return NULL;
2382-
}
2383-
/* DTypes may currently get filled in fallbacks and XDECREF for error: */
2375+
int res = resolve_descriptors(3, ufunc, ufuncimpl,
2376+
ops, out_descrs, signature, operation_DTypes, NULL, casting);
2377+
23842378
Py_XDECREF(operation_DTypes[0]);
23852379
Py_XDECREF(operation_DTypes[1]);
23862380
Py_XDECREF(operation_DTypes[2]);
2381+
if (res < 0) {
2382+
return NULL;
2383+
}
23872384

23882385
/*
23892386
* The first operand and output should be the same array, so they should

0 commit comments

Comments
 (0)