Commit 66eaf84b authored by Damien George's avatar Damien George
Browse files

py: Replace mp_const_stop_iteration object with MP_OBJ_NULL.

parent 688e220d
...@@ -103,7 +103,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs); ...@@ -103,7 +103,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
mp_obj_t iterable = rt_getiter(o_in); mp_obj_t iterable = rt_getiter(o_in);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (!rt_is_true(item)) { if (!rt_is_true(item)) {
return mp_const_false; return mp_const_false;
} }
...@@ -116,7 +116,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all); ...@@ -116,7 +116,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
mp_obj_t iterable = rt_getiter(o_in); mp_obj_t iterable = rt_getiter(o_in);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (rt_is_true(item)) { if (rt_is_true(item)) {
return mp_const_true; return mp_const_true;
} }
...@@ -232,7 +232,7 @@ STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) { ...@@ -232,7 +232,7 @@ STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args) {
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t max_obj = NULL; mp_obj_t max_obj = NULL;
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (max_obj == NULL || mp_obj_less(max_obj, item)) { if (max_obj == NULL || mp_obj_less(max_obj, item)) {
max_obj = item; max_obj = item;
} }
...@@ -261,7 +261,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) { ...@@ -261,7 +261,7 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t min_obj = NULL; mp_obj_t min_obj = NULL;
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (min_obj == NULL || mp_obj_less(item, min_obj)) { if (min_obj == NULL || mp_obj_less(item, min_obj)) {
min_obj = item; min_obj = item;
} }
...@@ -285,8 +285,8 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) { ...@@ -285,8 +285,8 @@ STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args) {
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min); MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin_min_obj, 1, mp_builtin_min);
STATIC mp_obj_t mp_builtin_next(mp_obj_t o) { STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
mp_obj_t ret = rt_iternext(o); mp_obj_t ret = rt_iternext_allow_raise(o);
if (ret == mp_const_stop_iteration) { if (ret == MP_OBJ_NULL) {
nlr_jump(mp_obj_new_exception(&mp_type_StopIteration)); nlr_jump(mp_obj_new_exception(&mp_type_StopIteration));
} else { } else {
return ret; return ret;
...@@ -362,7 +362,7 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) { ...@@ -362,7 +362,7 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
} }
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
value = rt_binary_op(RT_BINARY_OP_ADD, value, item); value = rt_binary_op(RT_BINARY_OP_ADD, value, item);
} }
return value; return value;
......
...@@ -987,7 +987,7 @@ STATIC void emit_native_for_iter(emit_t *emit, int label) { ...@@ -987,7 +987,7 @@ STATIC void emit_native_for_iter(emit_t *emit, int label) {
emit_access_stack(emit, 1, &vtype, REG_ARG_1); emit_access_stack(emit, 1, &vtype, REG_ARG_1);
assert(vtype == VTYPE_PYOBJ); assert(vtype == VTYPE_PYOBJ);
emit_call(emit, RT_F_ITERNEXT, rt_iternext); emit_call(emit, RT_F_ITERNEXT, rt_iternext);
ASM_MOV_IMM_TO_REG((machine_uint_t)mp_const_stop_iteration, REG_TEMP1); ASM_MOV_IMM_TO_REG((machine_uint_t)MP_OBJ_NULL, REG_TEMP1);
#if N_X64 #if N_X64
asm_x64_cmp_r64_with_r64(emit->as, REG_RET, REG_TEMP1); asm_x64_cmp_r64_with_r64(emit->as, REG_RET, REG_TEMP1);
asm_x64_jcc_label(emit->as, JCC_JE, label); asm_x64_jcc_label(emit->as, JCC_JE, label);
......
...@@ -152,7 +152,7 @@ struct _mp_obj_type_t { ...@@ -152,7 +152,7 @@ struct _mp_obj_type_t {
mp_store_item_fun_t store_item; mp_store_item_fun_t store_item;
mp_fun_1_t getiter; mp_fun_1_t getiter;
mp_fun_1_t iternext; mp_fun_1_t iternext; // may return MP_OBJ_NULL as an optimisation instead of raising StopIteration() (with no args)
// Alternatively, pointer(s) to interfaces to save space // Alternatively, pointer(s) to interfaces to save space
// in mp_obj_type_t at the expense of extra pointer and extra dereference // in mp_obj_type_t at the expense of extra pointer and extra dereference
...@@ -221,7 +221,6 @@ extern const mp_obj_t mp_const_false; ...@@ -221,7 +221,6 @@ extern const mp_obj_t mp_const_false;
extern const mp_obj_t mp_const_true; extern const mp_obj_t mp_const_true;
extern const mp_obj_t mp_const_empty_tuple; extern const mp_obj_t mp_const_empty_tuple;
extern const mp_obj_t mp_const_ellipsis; extern const mp_obj_t mp_const_ellipsis;
extern const mp_obj_t mp_const_stop_iteration; // special object indicating end of iteration (not StopIteration exception!)
// General API for objects // General API for objects
......
...@@ -64,7 +64,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) { ...@@ -64,7 +64,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
mp_obj_t iterable = rt_getiter(initializer); mp_obj_t iterable = rt_getiter(initializer);
mp_obj_t item; mp_obj_t item;
int i = 0; int i = 0;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (len == 0) { if (len == 0) {
array_append(array, item); array_append(array, item);
} else { } else {
...@@ -212,7 +212,7 @@ STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) { ...@@ -212,7 +212,7 @@ STATIC mp_obj_t array_it_iternext(mp_obj_t self_in) {
if (self->cur < self->array->len) { if (self->cur < self->array->len) {
return mp_binary_get_val(self->array->typecode, self->array->items, self->cur++); return mp_binary_get_val(self->array->typecode, self->array->items, self->cur++);
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
......
...@@ -106,7 +106,7 @@ mp_obj_t dict_it_iternext(mp_obj_t self_in) { ...@@ -106,7 +106,7 @@ mp_obj_t dict_it_iternext(mp_obj_t self_in) {
if (next != NULL) { if (next != NULL) {
return next->key; return next->key;
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
...@@ -171,7 +171,7 @@ STATIC mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) { ...@@ -171,7 +171,7 @@ STATIC mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) {
self = mp_obj_new_dict(MP_OBJ_SMALL_INT_VALUE(len)); self = mp_obj_new_dict(MP_OBJ_SMALL_INT_VALUE(len));
} }
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value; mp_map_lookup(&self->map, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
} }
...@@ -266,14 +266,14 @@ STATIC mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) { ...@@ -266,14 +266,14 @@ STATIC mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) {
/* TODO: check for the "keys" method */ /* TODO: check for the "keys" method */
mp_obj_t iter = rt_getiter(iterable); mp_obj_t iter = rt_getiter(iterable);
mp_obj_t next = NULL; mp_obj_t next = NULL;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
mp_obj_t inneriter = rt_getiter(next); mp_obj_t inneriter = rt_getiter(next);
mp_obj_t key = rt_iternext(inneriter); mp_obj_t key = rt_iternext(inneriter);
mp_obj_t value = rt_iternext(inneriter); mp_obj_t value = rt_iternext(inneriter);
mp_obj_t stop = rt_iternext(inneriter); mp_obj_t stop = rt_iternext(inneriter);
if (key == mp_const_stop_iteration if (key == MP_OBJ_NULL
|| value == mp_const_stop_iteration || value == MP_OBJ_NULL
|| stop != mp_const_stop_iteration) { || stop != MP_OBJ_NULL) {
nlr_jump(mp_obj_new_exception_msg( nlr_jump(mp_obj_new_exception_msg(
&mp_type_ValueError, &mp_type_ValueError,
"dictionary update sequence has the wrong length")); "dictionary update sequence has the wrong length"));
...@@ -335,7 +335,7 @@ STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) { ...@@ -335,7 +335,7 @@ STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
return mp_const_none; return mp_const_none;
} }
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
...@@ -364,7 +364,7 @@ STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void ...@@ -364,7 +364,7 @@ STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void
print(env, "(["); print(env, "([");
mp_obj_t *self_iter = dict_view_getiter(self); mp_obj_t *self_iter = dict_view_getiter(self);
mp_obj_t *next = NULL; mp_obj_t *next = NULL;
while ((next = dict_view_it_iternext(self_iter)) != mp_const_stop_iteration) { while ((next = dict_view_it_iternext(self_iter)) != MP_OBJ_NULL) {
if (!first) { if (!first) {
print(env, ", "); print(env, ", ");
} }
......
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "misc.h" #include "misc.h"
...@@ -37,8 +38,8 @@ STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) { ...@@ -37,8 +38,8 @@ STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &enumerate_type)); assert(MP_OBJ_IS_TYPE(self_in, &enumerate_type));
mp_obj_enumerate_t *self = self_in; mp_obj_enumerate_t *self = self_in;
mp_obj_t next = rt_iternext(self->iter); mp_obj_t next = rt_iternext(self->iter);
if (next == mp_const_stop_iteration) { if (next == MP_OBJ_NULL) {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} else { } else {
mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(self->cur++), next}; mp_obj_t items[] = {MP_OBJ_NEW_SMALL_INT(self->cur++), next};
return mp_obj_new_tuple(2, items); return mp_obj_new_tuple(2, items);
......
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "nlr.h" #include "nlr.h"
...@@ -29,7 +30,7 @@ STATIC mp_obj_t filter_iternext(mp_obj_t self_in) { ...@@ -29,7 +30,7 @@ STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &filter_type)); assert(MP_OBJ_IS_TYPE(self_in, &filter_type));
mp_obj_filter_t *self = self_in; mp_obj_filter_t *self = self_in;
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(self->iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(self->iter)) != MP_OBJ_NULL) {
mp_obj_t val; mp_obj_t val;
if (self->fun != mp_const_none) { if (self->fun != mp_const_none) {
val = rt_call_function_n_kw(self->fun, 1, 0, &next); val = rt_call_function_n_kw(self->fun, 1, 0, &next);
...@@ -40,7 +41,7 @@ STATIC mp_obj_t filter_iternext(mp_obj_t self_in) { ...@@ -40,7 +41,7 @@ STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
return next; return next;
} }
} }
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
const mp_obj_type_t filter_type = { const mp_obj_type_t filter_type = {
......
...@@ -78,7 +78,7 @@ mp_obj_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw ...@@ -78,7 +78,7 @@ mp_obj_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_value, mp_obj_t throw
mp_obj_gen_instance_t *self = self_in; mp_obj_gen_instance_t *self = self_in;
if (self->ip == 0) { if (self->ip == 0) {
*ret_kind = MP_VM_RETURN_NORMAL; *ret_kind = MP_VM_RETURN_NORMAL;
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
if (self->sp == self->state - 1) { if (self->sp == self->state - 1) {
if (send_value != mp_const_none) { if (send_value != mp_const_none) {
...@@ -122,7 +122,7 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o ...@@ -122,7 +122,7 @@ STATIC mp_obj_t gen_resume_and_raise(mp_obj_t self_in, mp_obj_t send_value, mp_o
case MP_VM_RETURN_NORMAL: case MP_VM_RETURN_NORMAL:
// Optimize return w/o value in case generator is used in for loop // Optimize return w/o value in case generator is used in for loop
if (ret == mp_const_none) { if (ret == mp_const_none) {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} else { } else {
nlr_jump(mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret)); nlr_jump(mp_obj_new_exception_args(&mp_type_StopIteration, 1, &ret));
} }
...@@ -145,7 +145,7 @@ mp_obj_t gen_instance_iternext(mp_obj_t self_in) { ...@@ -145,7 +145,7 @@ mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) { STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
mp_obj_t ret = gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL); mp_obj_t ret = gen_resume_and_raise(self_in, send_value, MP_OBJ_NULL);
if (ret == mp_const_stop_iteration) { if (ret == MP_OBJ_NULL) {
nlr_jump(mp_obj_new_exception(&mp_type_StopIteration)); nlr_jump(mp_obj_new_exception(&mp_type_StopIteration));
} else { } else {
return ret; return ret;
...@@ -156,7 +156,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send); ...@@ -156,7 +156,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
STATIC mp_obj_t gen_instance_throw(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t gen_instance_throw(uint n_args, const mp_obj_t *args) {
mp_obj_t ret = gen_resume_and_raise(args[0], mp_const_none, n_args == 2 ? args[1] : args[2]); mp_obj_t ret = gen_resume_and_raise(args[0], mp_const_none, n_args == 2 ? args[1] : args[2]);
if (ret == mp_const_stop_iteration) { if (ret == MP_OBJ_NULL) {
nlr_jump(mp_obj_new_exception(&mp_type_StopIteration)); nlr_jump(mp_obj_new_exception(&mp_type_StopIteration));
} else { } else {
return ret; return ret;
......
#include <stdlib.h>
#include "nlr.h" #include "nlr.h"
#include "misc.h" #include "misc.h"
...@@ -25,8 +26,8 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) { ...@@ -25,8 +26,8 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
} else { } else {
// an exception was raised // an exception was raised
if (mp_obj_get_type(nlr.ret_val) == &mp_type_StopIteration) { if (mp_obj_get_type(nlr.ret_val) == &mp_type_StopIteration) {
// return mp_const_stop_iteration instead of raising StopIteration // return MP_OBJ_NULL instead of raising StopIteration
return mp_const_stop_iteration; return MP_OBJ_NULL;
} else { } else {
// re-raise exception // re-raise exception
nlr_jump(nlr.ret_val); nlr_jump(nlr.ret_val);
......
...@@ -53,7 +53,7 @@ STATIC mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp ...@@ -53,7 +53,7 @@ STATIC mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t list = mp_obj_new_list(0, NULL); mp_obj_t list = mp_obj_new_list(0, NULL);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
mp_obj_list_append(list, item); mp_obj_list_append(list, item);
} }
return list; return list;
...@@ -401,7 +401,7 @@ mp_obj_t list_it_iternext(mp_obj_t self_in) { ...@@ -401,7 +401,7 @@ mp_obj_t list_it_iternext(mp_obj_t self_in) {
self->cur += 1; self->cur += 1;
return o_out; return o_out;
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
......
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include "nlr.h" #include "nlr.h"
...@@ -40,9 +41,9 @@ STATIC mp_obj_t map_iternext(mp_obj_t self_in) { ...@@ -40,9 +41,9 @@ STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
for (int i = 0; i < self->n_iters; i++) { for (int i = 0; i < self->n_iters; i++) {
mp_obj_t next = rt_iternext(self->iters[i]); mp_obj_t next = rt_iternext(self->iters[i]);
if (next == mp_const_stop_iteration) { if (next == MP_OBJ_NULL) {
m_del(mp_obj_t, nextses, self->n_iters); m_del(mp_obj_t, nextses, self->n_iters);
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
nextses[i] = next; nextses[i] = next;
} }
......
...@@ -31,8 +31,3 @@ const mp_obj_type_t none_type = { ...@@ -31,8 +31,3 @@ const mp_obj_type_t none_type = {
STATIC const mp_obj_none_t none_obj = {{&none_type}}; STATIC const mp_obj_none_t none_obj = {{&none_type}};
const mp_obj_t mp_const_none = (mp_obj_t)&none_obj; const mp_obj_t mp_const_none = (mp_obj_t)&none_obj;
// the stop-iteration object just needs to be something unique
// it's not the StopIteration exception
STATIC const mp_obj_none_t stop_it_obj = {{&none_type}};
const mp_obj_t mp_const_stop_iteration = (mp_obj_t)&stop_it_obj;
#include <stdlib.h>
#include "nlr.h" #include "nlr.h"
#include "misc.h" #include "misc.h"
...@@ -55,7 +56,7 @@ STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) { ...@@ -55,7 +56,7 @@ STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
o->cur += o->step; o->cur += o->step;
return o_out; return o_out;
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
......
...@@ -59,7 +59,7 @@ STATIC mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_ ...@@ -59,7 +59,7 @@ STATIC mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
mp_obj_t set = mp_obj_new_set(0, NULL); mp_obj_t set = mp_obj_new_set(0, NULL);
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
mp_obj_set_store(set, item); mp_obj_set_store(set, item);
} }
return set; return set;
...@@ -89,7 +89,7 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) { ...@@ -89,7 +89,7 @@ STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
} }
} }
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
STATIC mp_obj_t set_getiter(mp_obj_t set_in) { STATIC mp_obj_t set_getiter(mp_obj_t set_in) {
...@@ -162,7 +162,7 @@ STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) { ...@@ -162,7 +162,7 @@ STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
} else { } else {
mp_obj_t iter = rt_getiter(other); mp_obj_t iter = rt_getiter(other);
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
set_discard(self, next); set_discard(self, next);
} }
} }
...@@ -193,7 +193,7 @@ STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) ...@@ -193,7 +193,7 @@ STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update)
mp_obj_t iter = rt_getiter(other); mp_obj_t iter = rt_getiter(other);
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) {
set_add(out, next); set_add(out, next);
} }
...@@ -225,7 +225,7 @@ STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) { ...@@ -225,7 +225,7 @@ STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
mp_obj_t iter = rt_getiter(other); mp_obj_t iter = rt_getiter(other);
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) { if (mp_set_lookup(&self->set, next, MP_MAP_LOOKUP)) {
return mp_const_false; return mp_const_false;
} }
...@@ -258,7 +258,7 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool ...@@ -258,7 +258,7 @@ STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool
} else { } else {
mp_obj_t iter = set_getiter(self); mp_obj_t iter = set_getiter(self);
mp_obj_t next; mp_obj_t next;
while ((next = set_it_iternext(iter)) != mp_const_stop_iteration) { while ((next = set_it_iternext(iter)) != MP_OBJ_NULL) {
if (!mp_set_lookup(&other->set, next, MP_MAP_LOOKUP)) { if (!mp_set_lookup(&other->set, next, MP_MAP_LOOKUP)) {
out = false; out = false;
break; break;
...@@ -332,7 +332,7 @@ STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other ...@@ -332,7 +332,7 @@ STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other
mp_obj_set_t *self = self_in; mp_obj_set_t *self = self_in;
mp_obj_t iter = rt_getiter(other_in); mp_obj_t iter = rt_getiter(other_in);
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_REMOVE_IF_FOUND | MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_REMOVE_IF_FOUND | MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
} }
return mp_const_none; return mp_const_none;
...@@ -350,7 +350,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_dif ...@@ -350,7 +350,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_dif
STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) { STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
mp_obj_t iter = rt_getiter(other_in); mp_obj_t iter = rt_getiter(other_in);
mp_obj_t next; mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) { while ((next = rt_iternext(iter)) != MP_OBJ_NULL) {
mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); mp_set_lookup(&self->set, next, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
} }
} }
......
...@@ -161,7 +161,7 @@ STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m ...@@ -161,7 +161,7 @@ STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (len == -1) { if (len == -1) {
vstr_add_char(vstr, MP_OBJ_SMALL_INT_VALUE(item)); vstr_add_char(vstr, MP_OBJ_SMALL_INT_VALUE(item));
} else { } else {
...@@ -877,7 +877,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) { ...@@ -877,7 +877,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
self->cur += 1; self->cur += 1;
return o_out; return o_out;
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
...@@ -895,7 +895,7 @@ STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) { ...@@ -895,7 +895,7 @@ STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
self->cur += 1; self->cur += 1;
return o_out; return o_out;
} else { } else {
return mp_const_stop_iteration; return MP_OBJ_NULL;
} }
} }
......
...@@ -53,7 +53,7 @@ STATIC mp_obj_t tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m ...@@ -53,7 +53,7 @@ STATIC mp_obj_t tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
mp_obj_t iterable = rt_getiter(args[0]); mp_obj_t iterable = rt_getiter(args[0]);
mp_obj_t item; mp_obj_t item;
while ((item = rt_iternext(iterable)) != mp_const_stop_iteration) { while ((item = rt_iternext(iterable)) != MP_OBJ_NULL) {
if (len >= alloc) { if (len >= alloc) {
items = m_renew(mp_obj_t, items, alloc, alloc * 2); items = m_renew(mp_obj_t, items, alloc, alloc * 2);
alloc *= 2; alloc *= 2;
...@@ -245,7 +245,7 @@ STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) { ...@@ -245,7 +245,7 @@ STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {