summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-02-02 08:57:05 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-02-02 08:58:16 +0200
commitea2509d92cbb222854ceb0b323b616b807dd221b (patch)
tree9cc30cf55b4c563be2fe139996f727815732eb0e
parent6964422cf426164b39abdc66f260be4f582309e0 (diff)
downloadmicropython-ea2509d92cbb222854ceb0b323b616b807dd221b.tar.gz
micropython-ea2509d92cbb222854ceb0b323b616b807dd221b.zip
Fix assert() usage.
-rw-r--r--py/objlist.c4
-rw-r--r--py/objstr.c4
-rw-r--r--py/objtuple.c4
3 files changed, 9 insertions, 3 deletions
diff --git a/py/objlist.c b/py/objlist.c
index f3db99a637..59a4ad6b12 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -139,7 +139,9 @@ static mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
#if MICROPY_ENABLE_SLICE
if (MP_OBJ_IS_TYPE(rhs, &slice_type)) {
machine_uint_t start, stop;
- assert(m_seq_get_fast_slice_indexes(o->len, rhs, &start, &stop));
+ if (!m_seq_get_fast_slice_indexes(o->len, rhs, &start, &stop)) {
+ assert(0);
+ }
mp_obj_list_t *res = list_new(stop - start);
m_seq_copy(res->items, o->items + start, res->len, mp_obj_t);
return res;
diff --git a/py/objstr.c b/py/objstr.c
index 50cd31d542..03602b6ec7 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -116,7 +116,9 @@ mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
#if MICROPY_ENABLE_SLICE
} else if (MP_OBJ_IS_TYPE(rhs_in, &slice_type)) {
machine_uint_t start, stop;
- assert(m_seq_get_fast_slice_indexes(lhs_len, rhs_in, &start, &stop));
+ if (!m_seq_get_fast_slice_indexes(lhs_len, rhs_in, &start, &stop)) {
+ assert(0);
+ }
return mp_obj_new_str(lhs_data + start, stop - start, false);
#endif
} else {
diff --git a/py/objtuple.c b/py/objtuple.c
index da714e08a3..3e5041c9dd 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -91,7 +91,9 @@ static mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
#if MICROPY_ENABLE_SLICE
if (MP_OBJ_IS_TYPE(rhs, &slice_type)) {
machine_uint_t start, stop;
- assert(m_seq_get_fast_slice_indexes(o->len, rhs, &start, &stop));
+ if (!m_seq_get_fast_slice_indexes(o->len, rhs, &start, &stop)) {
+ assert(0);
+ }
mp_obj_tuple_t *res = mp_obj_new_tuple(stop - start, NULL);
m_seq_copy(res->items, o->items + start, res->len, mp_obj_t);
return res;