Skip to content

Commit fdca17c

Browse files
committed
BUG: Fix misplaced return.
Backport of #20980. This lead to crashes when casting failed with an error already set. Internally to NumPy, this is exceedingly rare (maybe impossible aside from catastrophic failures, such as out-of-memory).
1 parent aa358cc commit fdca17c

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎numpy/core/src/multiarray/dtype_transfer.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3021,9 +3021,9 @@ init_cast_info(NPY_cast_info *cast_info, NPY_CASTING *casting,
30213021
if (!PyErr_Occurred()) {
30223022
PyErr_Format(PyExc_TypeError,
30233023
"Cannot cast array data from %R to %R.", src_dtype, dst_dtype);
3024-
Py_DECREF(meth);
3025-
return -1;
30263024
}
3025+
Py_DECREF(meth);
3026+
return -1;
30273027
}
30283028
assert(PyArray_DescrCheck(cast_info->descriptors[0]));
30293029
assert(PyArray_DescrCheck(cast_info->descriptors[1]));

0 commit comments

Comments
 (0)