Browse Source

py/objenumerate: Check for valid args in enumerate constructor.

For the case where MICROPY_CPYTHON_COMPAT is disabled.  This fix makes
basics/fun_error2.py pass and not crash the interpreter.
pull/5403/head
Emil Renner Berthing 5 years ago
committed by Damien George
parent
commit
4ebbacd65e
  1. 2
      py/objenumerate.c

2
py/objenumerate.c

@ -59,7 +59,7 @@ STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, siz
o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL);
o->cur = arg_vals.start.u_int;
#else
(void)n_kw;
mp_arg_check_num(n_args, n_kw, 1, 2, false);
mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
o->base.type = type;
o->iter = mp_getiter(args[0], NULL);

Loading…
Cancel
Save