Use OverflowError exception type for overflows
Initially I used one of the existing exception raise functions, but it's more correct and not much more code to raise OverflowError instead.
This commit is contained in:
parent
095c844004
commit
f325bd848b
@ -340,7 +340,7 @@ void mp_obj_int_buffer_overflow_check(mp_obj_t self_in, size_t nbytes, bool is_s
|
||||
return;
|
||||
|
||||
raise:
|
||||
mp_raise_ValueError_varg(translate("value would overflow a %d byte buffer"), nbytes);
|
||||
mp_raise_OverflowError_varg(translate("value would overflow a %d byte buffer"), nbytes);
|
||||
}
|
||||
|
||||
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE
|
||||
|
@ -1598,6 +1598,14 @@ NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt,
|
||||
nlr_raise(exception);
|
||||
}
|
||||
|
||||
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...) {
|
||||
va_list argptr;
|
||||
va_start(argptr,fmt);
|
||||
mp_obj_t exception = mp_obj_new_exception_msg_vlist(&mp_type_OverflowError, fmt, argptr);
|
||||
va_end(argptr);
|
||||
nlr_raise(exception);
|
||||
}
|
||||
|
||||
NORETURN void mp_raise_MpyError(const compressed_string_t *msg) {
|
||||
mp_raise_msg(&mp_type_MpyError, msg);
|
||||
}
|
||||
|
@ -163,6 +163,7 @@ NORETURN void mp_raise_OSError_msg(const compressed_string_t *msg);
|
||||
NORETURN void mp_raise_OSError_msg_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_NotImplementedError(const compressed_string_t *msg);
|
||||
NORETURN void mp_raise_NotImplementedError_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_OverflowError_varg(const compressed_string_t *fmt, ...);
|
||||
NORETURN void mp_raise_MpyError(const compressed_string_t *msg);
|
||||
NORETURN void mp_raise_recursion_depth(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user