Skip to content

Commit 23a4371

Browse files
Make release method for py_ref return an owned or borrowed reference
depending on the type of reference the smart pointer wraps.
1 parent 9c23996 commit 23a4371

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

dynd/include/utility_functions.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,10 @@ class py_ref_tmpl {
384384
}
385385
}
386386

387-
// Return an owned reference to the encapsulated PyObject as a raw pointer.
387+
// Return a reference to the encapsulated PyObject as a raw pointer.
388388
// Set the encapsulated pointer to NULL.
389+
// If this is a type that owns its reference, an owned reference is returned.
390+
// If this is a type that wraps a borrowed reference, a borrowed reference is returned.
389391
PyObject *release() noexcept
390392
{
391393
// If the contained reference should not be null, assert that it isn't.
@@ -394,7 +396,6 @@ class py_ref_tmpl {
394396
PYDYND_ASSERT_IF(o != nullptr, Py_REFCNT(o) > 0);
395397
auto ret = o;
396398
o = nullptr;
397-
incref_if_owned<!owns_ref, not_null>(ret);
398399
return ret;
399400
}
400401

0 commit comments

Comments
 (0)