File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -387,14 +387,18 @@ class py_ref_t {
387387 // Return a wrapped borrowed reference to the wrapped reference.
388388 py_ref_t <false , not_null> borrow () noexcept
389389 {
390+ // Assert that the wrapped pointer is not null if it shouldn't be.
391+ PYDYND_ASSERT_IF (not_null, o != nullptr );
390392 // Assert that the wrapped reference is actually valid if it isn't null.
391393 PYDYND_ASSERT_IF (o != nullptr , Py_REFCNT (o) > 0 );
392394 return py_ref_t <false , not_null>(o, false );
393395 }
394396
395397 // Return a wrapped owned reference referring to the currently wrapped reference.
396- py_ref_t <true , not_null> borrow () noexcept
398+ py_ref_t <true , not_null> new_ownref () noexcept
397399 {
400+ // Assert that the wrapped pointer is not null if it shouldn't be.
401+ PYDYND_ASSERT_IF (not_null, o != nullptr );
398402 // Assert that the wrapped reference is actually valid if it isn't null.
399403 PYDYND_ASSERT_IF (o != nullptr , Py_REFCNT (o) > 0 );
400404 return py_ref_t <true , not_null>(o, false );
You can’t perform that action at this time.
0 commit comments