Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Py Bindings: Remove pointless borrowing of arguments #3033

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/nrnpython/nrnpy_nrn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,8 @@ static Object* pysec_cell(Section* sec) {
}

static int NpySObj_contains(PyObject* s, PyObject* obj, const char* string) {
/* Checks is provided PyObject* s matches obj.<string> */
auto pyobj = nb::borrow(obj); // keep refcount+1 during use
/* Checks if provided PyObject* s matches obj.<string> */
nb::handle pyobj{obj};
ferdonline marked this conversation as resolved.
Show resolved Hide resolved
if (!nb::hasattr(pyobj, string)) {
return 0;
}
Expand Down Expand Up @@ -1498,7 +1498,6 @@ static PyObject* NPySecObj_insert(NPySecObj* self, PyObject* args) {
// if called with an object that has an insert method, use that
PyObject* tpyobj;
if (PyArg_ParseTuple(args, "O", &tpyobj)) {
auto _tpyobj_tracker = nb::borrow(tpyobj);
// Returned object to be discarded
auto out_o = nb::steal(PyObject_CallMethod(tpyobj, "insert", "O", (PyObject*) self));
if (!out_o.is_valid()) {
Expand Down Expand Up @@ -1975,7 +1974,6 @@ static PyObject* section_getattro(NPySecObj* self, PyObject* pyname) {
Section* sec = self->sec_;
CHECK_SEC_INVALID(sec);
PyObject* rv;
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
ferdonline marked this conversation as resolved.
Show resolved Hide resolved
char* n = name.c_str();
if (name.err()) {
Expand Down Expand Up @@ -2035,7 +2033,6 @@ static int section_setattro(NPySecObj* self, PyObject* pyname, PyObject* value)
}
PyObject* rv;
int err = 0;
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
char* n = name.c_str();
if (name.err()) {
Expand Down Expand Up @@ -2188,7 +2185,6 @@ static PyObject* segment_getattro(NPySegObj* self, PyObject* pyname) {
CHECK_SEC_INVALID(sec)

Symbol* sym;
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
char* n = name.c_str();
if (name.err()) {
Expand Down Expand Up @@ -2330,7 +2326,6 @@ static int segment_setattro(NPySegObj* self, PyObject* pyname, PyObject* value)
PyObject* rv;
Symbol* sym;
int err = 0;
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
char* n = name.c_str();
if (name.err()) {
Expand Down Expand Up @@ -2480,7 +2475,6 @@ static PyObject* mech_getattro(NPyMechObj* self, PyObject* pyname) {
Section* sec = self->pyseg_->pysec_->sec_;
CHECK_SEC_INVALID(sec)
CHECK_PROP_INVALID(self->prop_id_);
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
char* n = name.c_str();
if (!n) {
Expand Down Expand Up @@ -2574,7 +2568,6 @@ static int mech_setattro(NPyMechObj* self, PyObject* pyname, PyObject* value) {
}

int err = 0;
auto _pyname_tracker = nb::borrow(pyname); // keep refcount+1 during use
Py2NRNString name(pyname);
char* n = name.c_str();
if (name.err()) {
Expand Down
Loading