diff options
Diffstat (limited to 'py/objmap.c')
-rw-r--r-- | py/objmap.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/py/objmap.c b/py/objmap.c index 2e07d76b7b..365735283a 100644 --- a/py/objmap.c +++ b/py/objmap.c @@ -1,8 +1,10 @@ #include <stdlib.h> #include <assert.h> +#include "nlr.h" #include "misc.h" #include "mpconfig.h" +#include "mpqstr.h" #include "obj.h" #include "runtime.h" @@ -15,8 +17,11 @@ typedef struct _mp_obj_map_t { static mp_obj_t map_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args) { /* NOTE: args are backwards */ - mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); + if (n_args < 2) { + nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "map must have at least 2 arguments")); + } assert(n_args >= 2); + mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1); o->base.type = &map_type; o->n_iters = n_args - 1; o->fun = args[n_args - 1]; |