Skip to content

Commit

Permalink
Modernize DECREF in get_plotshape_data (py_sl, py_obj).
Browse files Browse the repository at this point in the history
  • Loading branch information
1uc committed Nov 21, 2024
1 parent ae5f217 commit b30434d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2906,13 +2906,18 @@ extern "C" NRN_EXPORT PyObject* get_plotshape_data(PyObject* sp) {
spi = ((ShapePlotData*) that);
#endif
Object* sl = spi->neuron_section_list();
PyObject* py_sl = nrnpy_ho2po(sl);
PyObject* py_obj = (PyObject*) spi->varobj();
auto py_sl = nb::steal(nrnpy_ho2po(sl));
auto py_obj = nb::borrow((PyObject*) spi->varobj());
if (!py_obj) {
py_obj = Py_None;
py_obj = nb::none();

Check warning on line 2912 in src/nrnpython/nrnpy_hoc.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrnpython/nrnpy_hoc.cpp#L2912

Added line #L2912 was not covered by tests
}
// NOte: O increases the reference count; N does not
return Py_BuildValue("sOffN", spi->varname(), py_obj, spi->low(), spi->high(), py_sl);
return Py_BuildValue("sNffN",
spi->varname(),
py_obj.release().ptr(),

Check warning on line 2917 in src/nrnpython/nrnpy_hoc.cpp

View check run for this annotation

Codecov / codecov/patch

src/nrnpython/nrnpy_hoc.cpp#L2917

Added line #L2917 was not covered by tests
spi->low(),
spi->high(),
py_sl.release().ptr());
}

// poorly follows __reduce__ and __setstate__
Expand Down

0 comments on commit b30434d

Please sign in to comment.