diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-11-09 01:34:13 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2015-11-09 01:34:56 +0200 |
commit | 50f56227c651dfec18f0c72add3649ab0d678346 (patch) | |
tree | 2e88141475503f5f069ad11e1153968374326d05 | |
parent | c27e5c4b0bcdae50bdeb29a9c9b8adb431c343b3 (diff) | |
download | micropython-50f56227c651dfec18f0c72add3649ab0d678346.tar.gz micropython-50f56227c651dfec18f0c72add3649ab0d678346.zip |
py/objint_longlong: Instead of assert, throw OverflowError.
-rw-r--r-- | py/objint_longlong.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/py/objint_longlong.c b/py/objint_longlong.c index bceee095af..ea19b6804e 100644 --- a/py/objint_longlong.c +++ b/py/objint_longlong.c @@ -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; |