diff options
author | Damien George <damien.p.george@gmail.com> | 2014-01-25 00:17:36 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-01-25 00:17:36 +0000 |
commit | 7c9c667633d445e4df88868d630a0af4bc63d2f8 (patch) | |
tree | b130d6dc98ba1ecd47d8886ea13048a88a5a6865 /py/objstr.c | |
parent | fcd4ae827171717ea501bf833a6b6abd70edc5a3 (diff) | |
download | micropython-7c9c667633d445e4df88868d630a0af4bc63d2f8.tar.gz micropython-7c9c667633d445e4df88868d630a0af4bc63d2f8.zip |
py: Implement iterator support for object that has __getitem__.
Addresses Issue #203.
Diffstat (limited to 'py/objstr.c')
-rw-r--r-- | py/objstr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/py/objstr.c b/py/objstr.c index 723eebd614..3a4d69cfcc 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -77,7 +77,7 @@ mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { if (MP_OBJ_IS_SMALL_INT(rhs_in)) { uint index = mp_get_index(mp_obj_get_type(lhs_in), lhs_len, rhs_in); if (MP_OBJ_IS_TYPE(lhs_in, &bytes_type)) { - return MP_OBJ_NEW_SMALL_INT(lhs_data[index]); + return MP_OBJ_NEW_SMALL_INT((mp_small_int_t)lhs_data[index]); } else { return mp_obj_new_str(lhs_data + index, 1, true); } @@ -549,7 +549,7 @@ mp_obj_t bytes_it_iternext(mp_obj_t self_in) { mp_obj_str_it_t *self = self_in; GET_STR_DATA_LEN(self->str, str, len); if (self->cur < len) { - mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(str[self->cur]); + mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT((mp_small_int_t)str[self->cur]); self->cur += 1; return o_out; } else { |