py/objint_longlong: Instead of assert, throw OverflowError.

This commit is contained in:
Paul Sokolovsky 2015-11-09 01:34:13 +02:00
parent c27e5c4b0b
commit 50f56227c6
1 changed files with 3 additions and 1 deletions

View File

@ -231,7 +231,9 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) {
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
// TODO raise an exception if the unsigned long long won't fit
assert(val >> (sizeof(unsigned long long) * 8 - 1) == 0);
if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OverflowError, "ulonglong too large"));
}
mp_obj_int_t *o = m_new_obj(mp_obj_int_t);
o->base.type = &mp_type_int;
o->val = val;