Add OverflowError and use it for small int overflow instead of assert.
diff --git a/py/objint.c b/py/objint.c
index 937bff7..59181ea 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -56,7 +56,7 @@
// 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 @@
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 @@
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