summaryrefslogtreecommitdiffstatshomepage
path: root/py/objint.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-18 12:46:43 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-01-18 12:46:43 +0200
commit166bb40fb22b9c43209ce9792b6a8d48276ef7fa (patch)
tree36dbf729377e077b37d4b5489347ee0a27b08425 /py/objint.c
parent8655065f8cec8b978d075adae1f65ffdfa9b51d8 (diff)
downloadmicropython-166bb40fb22b9c43209ce9792b6a8d48276ef7fa.tar.gz
micropython-166bb40fb22b9c43209ce9792b6a8d48276ef7fa.zip
Add OverflowError and use it for small int overflow instead of assert.
Diffstat (limited to 'py/objint.c')
-rw-r--r--py/objint.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/py/objint.c b/py/objint.c
index 937bff7ae3..59181eaf6d 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -56,7 +56,7 @@ mp_obj_t int_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
// This is called only with strings whose value doesn't fit in SMALL_INT
mp_obj_t mp_obj_new_int_from_long_str(const char *s) {
- assert(0);
+ nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "long int not supported in this build"));
return mp_const_none;
}
@@ -66,8 +66,7 @@ mp_obj_t mp_obj_new_int_from_uint(machine_uint_t value) {
if ((value & (WORD_MSBIT_HIGH | (WORD_MSBIT_HIGH >> 1))) == 0) {
return MP_OBJ_NEW_SMALL_INT(value);
}
- // TODO: Raise exception
- assert(0);
+ nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "small int overflow"));
return mp_const_none;
}
@@ -75,8 +74,7 @@ mp_obj_t mp_obj_new_int(machine_int_t value) {
if (MP_OBJ_FITS_SMALL_INT(value)) {
return MP_OBJ_NEW_SMALL_INT(value);
}
- // TODO: Raise exception
- assert(0);
+ nlr_jump(mp_obj_new_exception_msg(MP_QSTR_OverflowError, "small int overflow"));
return mp_const_none;
}
#endif