Skip to content

Commit

Permalink
Modernize DECREF in rvp_rxd_to_callable_ (py_obj).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 18, 2024
1 parent f35b215 commit 50e86e0
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2866,12 +2866,10 @@ static Object** nrnpy_vec_to_python(void* v) {

static Object* rvp_rxd_to_callable_(Object* obj) {
if (obj) {
PyObject* py_obj = nrnpy_ho2po(obj);
PyObject* result = PyObject_CallFunctionObjArgs(nrnpy_rvp_pyobj_callback, py_obj, NULL);
Py_DECREF(py_obj);
Object* obj_result = nrnpy_po2ho(result);
Py_DECREF(result); // the previous line incremented the reference count
return obj_result;
auto py_obj = nb::steal(nrnpy_ho2po(obj));
auto result = nb::steal(
PyObject_CallFunctionObjArgs(nrnpy_rvp_pyobj_callback, py_obj.ptr(), NULL));
return nrnpy_po2ho(result.ptr());
} else {
return 0;
}
Expand Down

0 comments on commit 50e86e0

Please sign in to comment.