Skip to content

Commit

Permalink
BUG: Fix incorrect refcounting in new asarray path
Browse files Browse the repository at this point in the history
The new path to preserve dtypes provided by creating a view got the
reference counting wrong, because it also hit the incref path that
was needed for returning the identity.

This fixes up numpygh-21995

Closes numpygh-22233
  • Loading branch information
seberg committed Sep 9, 2022
1 parent 4a9b714 commit 3da24bb
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion numpy/core/src/multiarray/multiarraymodule.c
Expand Up @@ -1631,8 +1631,8 @@ _array_fromobject_generic(
oldtype = PyArray_DESCR(oparr);
if (PyArray_EquivTypes(oldtype, type)) {
if (copy != NPY_COPY_ALWAYS && STRIDING_OK(oparr, order)) {
Py_INCREF(op);
if (oldtype == type) {
Py_INCREF(op);
ret = oparr;
}
else {
Expand Down

0 comments on commit 3da24bb

Please sign in to comment.