mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
py: Add MP_OBJ_STOP_ITERATION and make good use of it.
Also make consistent use of MP_OBJ_NOT_SUPPORTED and MP_OBJ_NULL. This helps a lot in debugging and understanding of function API.
This commit is contained in:
@@ -26,8 +26,8 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
|
||||
} else {
|
||||
// an exception was raised
|
||||
if (mp_obj_get_type(nlr.ret_val) == &mp_type_StopIteration) {
|
||||
// return MP_OBJ_NULL instead of raising StopIteration
|
||||
return MP_OBJ_NULL;
|
||||
// return MP_OBJ_STOP_ITERATION instead of raising StopIteration
|
||||
return MP_OBJ_STOP_ITERATION;
|
||||
} else {
|
||||
// re-raise exception
|
||||
nlr_raise(nlr.ret_val);
|
||||
|
||||
Reference in New Issue
Block a user