Skip to content

Commit

Permalink
#306: throw exception when addressing out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Mar 22, 2023
1 parent 12a8bcf commit 9d0c8a2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/bindings/python/local-contrib.i
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,20 @@ class AutoProperty(type):
{
__metaclass__ = AutoProperty
}
}
}
%extend IdList
{
%pythoncode
{
def __len__(self):
return self.size()
def __getitem__(self, index):
return self.at(index)
def __iter__(self):
for i in range(self.size()):
yield self.at(i)
}
}
1 change: 1 addition & 0 deletions src/bindings/swig/libsbml.i
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ as a comment in the output stream.
%include sbml/common/common-documentation.h
%include sbml/common/common-sbmlerror-codes.h

%catches(std::exception, ...) IdList::at;
%include <sbml/util/IdList.h>
%include <sbml/util/IdentifierTransformer.h>
%include <sbml/util/ElementFilter.h>
Expand Down

0 comments on commit 9d0c8a2

Please sign in to comment.