8000 py/objint_longlong: Instead of assert, throw OverflowError. · rpavlik/circuitpython@50f5622 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50f5622

Browse files
committed
py/objint_longlong: Instead of assert, throw OverflowError.
1 parent c27e5c4 commit 50f5622

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

py/objint_longlong.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,9 @@ mp_obj_t mp_obj_new_int_from_ll(long long val) {
231231

232232
mp_obj_t mp_obj_new_int_from_ull(unsigned long long val) {
233233
// TODO raise an exception if the unsigned long long won't fit
234-
assert(val >> (sizeof(unsigned long long) * 8 - 1) == 0);
234+
if (val >> (sizeof(unsigned long long) * 8 - 1) != 0) {
235+
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OverflowError, "ulonglong too large"));
236+
}
235237
mp_obj_int_t *o = m_new_obj(mp_obj_int_t);
236238
o->base.type = &mp_type_int;
237239
o->val = val;

0 commit comments

Comments
 (0)
0