summaryrefslogtreecommitdiffstatshomepage
path: root/py/objstr.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-04-17 23:19:36 +0100
committerDamien George <damien.p.george@gmail.com>2014-04-17 23:19:36 +0100
commitea8d06c39d9c94036e490b300d46f367c9eb78d9 (patch)
treece4999f60f6ca57f22e7d536593a6198ceee0695 /py/objstr.c
parent1e935d8689f3d15dc3bd06f08f2a0305b7e1c7f4 (diff)
downloadmicropython-ea8d06c39d9c94036e490b300d46f367c9eb78d9.tar.gz
micropython-ea8d06c39d9c94036e490b300d46f367c9eb78d9.zip
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.
Diffstat (limited to 'py/objstr.c')
-rw-r--r--py/objstr.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/py/objstr.c b/py/objstr.c
index b9ca8a8ab7..e444ec7d41 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -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 = 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 == -1) {
vstr_add_char(vstr, MP_OBJ_SMALL_INT_VALUE(item));
} else {
@@ -285,7 +285,7 @@ STATIC mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
}
}
- return MP_OBJ_NULL; // op not supported
+ return MP_OBJ_NOT_SUPPORTED;
}
STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
@@ -1554,7 +1554,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
self->cur += 1;
return o_out;
} else {
- return MP_OBJ_NULL;
+ return MP_OBJ_STOP_ITERATION;
}
}
@@ -1573,7 +1573,7 @@ STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
self->cur += 1;
return o_out;
} else {
- return MP_OBJ_NULL;
+ return MP_OBJ_STOP_ITERATION;
}
}