From ea8d06c39d9c94036e490b300d46f367c9eb78d9 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 17 Apr 2014 23:19:36 +0100 Subject: 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. --- py/objtuple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'py/objtuple.c') diff --git a/py/objtuple.c b/py/objtuple.c index 57b313fd6..e6b902d74 100644 --- a/py/objtuple.c +++ b/py/objtuple.c @@ -52,7 +52,7 @@ mp_obj_t mp_obj_tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m mp_obj_t iterable = mp_getiter(args[0]); mp_obj_t item; - while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) { + while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) { if (len >= alloc) { items = m_renew(mp_obj_t, items, alloc, alloc * 2); alloc *= 2; @@ -88,7 +88,7 @@ mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) { switch (op) { case MP_UNARY_OP_BOOL: return MP_BOOL(self->len != 0); case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len); - default: return MP_OBJ_NULL; // op not supported for None + default: return MP_OBJ_NOT_SUPPORTED; } } @@ -249,7 +249,7 @@ STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) { self->cur += 1; return o_out; } else { - return MP_OBJ_NULL; + return MP_OBJ_STOP_ITERATION; } } -- cgit v1.2.3