Added boundary checking to Iterator::increment() and Iterator::decrement()

to avoid an immediate crash.  Now these methods raise a RuntimeError when
the iteration is already at the end.
This commit is contained in:
2009-07-31 23:16:38 +00:00
parent ba9943e4a7
commit 631df8cc01

View File

@@ -209,12 +209,20 @@ PyObject * Iterator_getExactTypeName(BPy_Iterator* self) {
PyObject * Iterator_increment(BPy_Iterator* self) {
if (self->it->isEnd()) {
PyErr_SetString(PyExc_RuntimeError , "cannot increment any more");
return NULL;
}
self->it->increment();
Py_RETURN_NONE;
}
PyObject * Iterator_decrement(BPy_Iterator* self) {
if (self->it->isBegin()) {
PyErr_SetString(PyExc_RuntimeError , "cannot decrement any more");
return NULL;
}
self->it->decrement();
Py_RETURN_NONE;