Merge branch 'master' of https://github.com/micropython/micropython
Conflicts: py/argcheck.c py/objenumerate.c py/runtime.h
This commit is contained in:
commit
c53b408f28
|
@ -109,3 +109,10 @@ void mp_arg_parse_all_kw_array(uint n_pos, uint n_kw, const mp_obj_t *args, uint
|
|||
mp_map_init_fixed_table(&kw_args, n_kw, args + n_pos);
|
||||
mp_arg_parse_all(n_pos, args, &kw_args, n_allowed, allowed, out_vals);
|
||||
}
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
NORETURN void mp_arg_error_unimpl_kw(void) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_NotImplementedError,
|
||||
"keyword argument(s) not yet implemented - use normal args instead"));
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -48,6 +48,7 @@ STATIC const mp_arg_t enumerate_make_new_args[] = {
|
|||
#define ENUMERATE_MAKE_NEW_NUM_ARGS ARRAY_SIZE(enumerate_make_new_args)
|
||||
|
||||
STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
// parse args
|
||||
mp_arg_val_t vals[ENUMERATE_MAKE_NEW_NUM_ARGS];
|
||||
mp_arg_parse_all_kw_array(n_args, n_kw, args, ENUMERATE_MAKE_NEW_NUM_ARGS, enumerate_make_new_args, vals);
|
||||
|
@ -57,6 +58,12 @@ STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
|
|||
o->base.type = &mp_type_enumerate;
|
||||
o->iter = mp_getiter(vals[0].u_obj);
|
||||
o->cur = vals[1].u_int;
|
||||
#else
|
||||
mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
|
||||
o->base.type = &mp_type_enumerate;
|
||||
o->iter = mp_getiter(args[0]);
|
||||
o->cur = n_args > 1 ? mp_obj_get_int(args[1]) : 0;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
|
|
12
py/objstr.c
12
py/objstr.c
|
@ -108,6 +108,12 @@ STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
|
|||
}
|
||||
|
||||
STATIC mp_obj_t str_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (n_kw != 0) {
|
||||
mp_arg_error_unimpl_kw();
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (n_args) {
|
||||
case 0:
|
||||
return MP_OBJ_NEW_QSTR(MP_QSTR_);
|
||||
|
@ -146,6 +152,12 @@ STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
|
|||
return mp_const_empty_bytes;
|
||||
}
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (n_kw != 0) {
|
||||
mp_arg_error_unimpl_kw();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (MP_OBJ_IS_STR(args[0])) {
|
||||
if (n_args < 2 || n_args > 3) {
|
||||
goto wrong_args;
|
||||
|
|
|
@ -57,6 +57,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);
|
||||
void mp_arg_parse_all_kw_array(uint n_pos, uint n_kw, const mp_obj_t *args, uint n_allowed, const mp_arg_t *allowed, mp_arg_val_t *out_vals);
|
||||
NORETURN void mp_arg_error_unimpl_kw(void);
|
||||
|
||||
mp_obj_dict_t *mp_locals_get(void);
|
||||
void mp_locals_set(mp_obj_dict_t *d);
|
||||
|
|
Loading…
Reference in New Issue