py: Make terse_arg_mismatch a global function and use it elsewhere.

Reduces code size when MICROPY_ERROR_REPORTING_TERSE is selected.
This commit is contained in:
Damien George
2015-01-01 15:33:50 +00:00
parent 276159e5dd
commit 7f23384d49
4 changed files with 39 additions and 24 deletions

View File

@@ -62,9 +62,8 @@ mp_uint_t mp_decode_uint(const byte **ptr) {
STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, mp_uint_t expected, mp_uint_t given) {
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
// Generic message, to be reused for other argument issues
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
"argument num/types mismatch"));
// generic message, used also for other argument issues
mp_arg_error_terse_mismatch();
#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
"function takes %d positional arguments but %d were given", expected, given));