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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy