py/objint: Add mp_obj_int_get_uint_checked() helper.
Can be used where mp_obj_int_get_checked() will overflow due to the sign-bit solely. This returns an mp_uint_t, so it also verifies the given integer is not negative. Currently implemented only for mpz configurations.
This commit is contained in:
committed by
Damien George
parent
1c849d63a8
commit
176ab99180
2
py/obj.h
2
py/obj.h
@@ -748,6 +748,8 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj);
|
||||
mp_int_t mp_obj_int_get_truncated(mp_const_obj_t self_in);
|
||||
// Will raise exception if value doesn't fit into mp_int_t
|
||||
mp_int_t mp_obj_int_get_checked(mp_const_obj_t self_in);
|
||||
// Will raise exception if value is negative or doesn't fit into mp_uint_t
|
||||
mp_uint_t mp_obj_int_get_uint_checked(mp_const_obj_t self_in);
|
||||
|
||||
// exception
|
||||
#define mp_obj_is_native_exception_instance(o) (mp_obj_get_type(o)->make_new == mp_obj_exception_make_new)
|
||||
|
||||
Reference in New Issue
Block a user