Skip to content

Commit

Permalink
Modernize DECREF in rvp_rxd_to_callable_ (py_obj & result).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 20, 2024
1 parent cbf38f2 commit e5d45e5
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 @@ -2843,12 +2843,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 e5d45e5

Please sign in to comment.