Skip to content

Commit

Permalink
Allow nested SectionList iteration in Python.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrnhines committed Nov 27, 2018
1 parent 85d62db commit 5174b0b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/nrnpython/nrnpy_hoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,9 +1453,11 @@ static PyObject* hocobj_iter(PyObject* self) {
} else if (po->ho_->ctemplate == hoc_list_template_) {
return PySeqIter_New(self);
} else if (po->ho_->ctemplate == hoc_sectionlist_template_) {
po->iteritem_ = ((hoc_Item*)po->ho_->u.this_pointer)->next;
Py_INCREF(self);
return self;
// need a clone of self so nested loops do not share iteritem_
PyObject* po2 = nrnpy_ho2po(po->ho_);
((PyHocObject*)po2)->iteritem_ = ((hoc_Item*)po->ho_->u.this_pointer)->next;
Py_INCREF(po2);
return po2;
}
} else if (po->type_ == PyHoc::HocForallSectionIterator) {
po->iteritem_ = section_list->next;
Expand Down

0 comments on commit 5174b0b

Please sign in to comment.