diff --git a/py/argcheck.c b/py/argcheck.c index 924a60c45585b2f7376c9e729f072dbb89bb718f..40c0cefb7a96c4d5e723d9c83899ad8a4e4b9abc 100644 --- a/py/argcheck.c +++ b/py/argcheck.c @@ -103,3 +103,10 @@ void mp_arg_parse_all(uint n_pos, const mp_obj_t *pos, mp_map_t *kws, uint n_all nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "extra keyword arguments given")); } } + +#if MICROPY_CPYTHON_COMPAT +void mp_arg_error_unimpl_kw() { + nlr_raise(mp_obj_new_exception_msg(&mp_type_NotImplementedError, + "keyword argument(s) not yet implemented - use normal args instead")); +} +#endif diff --git a/py/objenumerate.c b/py/objenumerate.c index fd428da4e38cf078a10b872e4a3cad324deccbe9..78169b31c4a85d849ccf018294ded528d02ac206 100644 --- a/py/objenumerate.c +++ b/py/objenumerate.c @@ -41,9 +41,14 @@ typedef struct _mp_obj_enumerate_t { STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in); -/* TODO: enumerate is one of the ones that can take args or kwargs. - Sticking to args for now */ STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { + /* TODO: enumerate is one of the ones that can take args or kwargs. + Sticking to args for now */ +#if MICROPY_CPYTHON_COMPAT + if (n_kw != 0) { + mp_arg_error_unimpl_kw(); + } +#endif assert(n_args > 0); mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t); o->base.type = &mp_type_enumerate; diff --git a/py/runtime.h b/py/runtime.h index 46be12dec723aac8a91bfb8a5634a357b8a8de3e..beb687e847701482f5cec0616dc1056c35d0da62 100644 --- a/py/runtime.h +++ b/py/runtime.h @@ -56,6 +56,7 @@ void mp_deinit(void); void mp_arg_check_num(uint n_args, uint n_kw, uint n_args_min, uint n_args_max, bool takes_kw); void mp_arg_parse_all(uint n_pos, const mp_obj_t *pos, mp_map_t *kws, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals); +NORETURN void mp_arg_error_unimpl_kw(); mp_obj_dict_t *mp_locals_get(void); void mp_locals_set(mp_obj_dict_t *d);