@@ -103,7 +103,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
103103STATIC mp_obj_t mp_builtin_all (mp_obj_t o_in ) {
104104 mp_obj_t iterable = rt_getiter (o_in );
105105 mp_obj_t item ;
106- while ((item = rt_iternext (iterable )) != mp_const_stop_iteration ) {
106+ while ((item = rt_iternext (iterable )) != MP_OBJ_NULL ) {
107107 if (!rt_is_true (item )) {
108108 return mp_const_false ;
109109 }
@@ -116,7 +116,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
116116STATIC mp_obj_t mp_builtin_any (mp_obj_t o_in ) {
117117 mp_obj_t iterable = rt_getiter (o_in );
118118 mp_obj_t item ;
119- while ((item = rt_iternext (iterable )) != mp_const_stop_iteration ) {
119+ while ((item = rt_iternext (iterable )) != MP_OBJ_NULL ) {
120120 if (rt_is_true (item )) {
121121 return mp_const_true ;
122122 }
@@ -232,7 +232,7 @@ STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
232232 mp_obj_t iterable = rt_getiter (args [0 ]);
233233 mp_obj_t max_obj = NULL ;
234234 mp_obj_t item ;
235- while ((item = rt_iternext (iterable )) != mp_const_stop_iteration ) {
235+ while ((item = rt_iternext (iterable )) != MP_OBJ_NULL ) {
236236 if (max_obj == NULL || mp_obj_less (max_obj , item )) {
237237 max_obj = item ;
238238 }
@@ -261,7 +261,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
261261 mp_obj_t iterable = rt_getiter (args [0 ]);
262262 mp_obj_t min_obj = NULL ;
263263 mp_obj_t item ;
264- while ((item = rt_iternext (iterable )) != mp_const_stop_iteration ) {
264+ while ((item = rt_iternext (iterable )) != MP_OBJ_NULL ) {
265265 if (min_obj == NULL || mp_obj_less (item , min_obj )) {
266266 min_obj = item ;
267267 }
@@ -285,8 +285,8 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
285285MP_DEFINE_CONST_FUN_OBJ_VAR (mp_builtin_min_obj , 1 , mp_builtin_min );
286286
287287STATIC mp_obj_t mp_builtin_next (mp_obj_t o ) {
288- mp_obj_t ret = rt_iternext (o );
289- if (ret == mp_const_stop_iteration ) {
288+ mp_obj_t ret = rt_iternext_allow_raise (o );
289+ if (ret == MP_OBJ_NULL ) {
290290 nlr_jump (mp_obj_new_exception (& mp_type_StopIteration ));
291291 } else {
292292 return ret ;
@@ -362,7 +362,7 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
362362 }
363363 mp_obj_t iterable = rt_getiter (args [0 ]);
364364 mp_obj_t item ;
365- while ((item = rt_iternext (iterable )) != mp_const_stop_iteration ) {
365+ while ((item = rt_iternext (iterable )) != MP_OBJ_NULL ) {
366366 value = rt_binary_op (RT_BINARY_OP_ADD , value , item );
367367 }
368368 return value ;
0 commit comments