Skip to content

Commit

Permalink
nb_ndarray: don't return reference to self when copy==true
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Jun 13, 2023
1 parent 1c038d1 commit ffd22b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/nb_ndarray.cpp
Expand Up @@ -611,13 +611,13 @@ PyObject *ndarray_wrap(ndarray_handle *th, int framework,
if (!th)
return none().release().ptr();

if (th->self) {
bool copy = policy == rv_policy::copy || policy == rv_policy::move;

if (th->self && !copy) {
Py_INCREF(th->self);
return th->self;
}

bool copy = policy == rv_policy::copy || policy == rv_policy::move;

if ((ndarray_framework) framework == ndarray_framework::numpy) {
try {
nb_ndarray *h = PyObject_New(nb_ndarray, nd_ndarray_tp());
Expand Down

0 comments on commit ffd22b0

Please sign in to comment.