diff options
| author | Dan Halbert <halbert@halwitz.org> | 2019-01-20 21:47:13 -0500 |
|---|---|---|
| committer | Dan Halbert <halbert@halwitz.org> | 2019-01-20 21:47:13 -0500 |
| commit | a8f4aa4796aaba964b17932f0ae9299d18db1649 (patch) | |
| tree | fea7576c8221fc5519ba86c8a97ddb601477cce3 /py | |
| parent | 7a09af73ec7f4a11a1404dff6276e09072d06983 (diff) | |
| parent | 6b88d0f94eb1459562d0f159688b504a6f5d408f (diff) | |
Merge remote-tracking branch 'adafruit/master' into struct-compat
Diffstat (limited to 'py')
| -rw-r--r-- | py/modio.c | 8 | ||||
| -rw-r--r-- | py/objdeque.c | 4 | ||||
| -rw-r--r-- | py/objdict.c | 5 | ||||
| -rw-r--r-- | py/objfun.c | 2 | ||||
| -rw-r--r-- | py/objnamedtuple.c | 5 |
5 files changed, 15 insertions, 9 deletions
diff --git a/py/modio.c b/py/modio.c index 9b09de96e..d7c1a58a8 100644 --- a/py/modio.c +++ b/py/modio.c @@ -46,11 +46,11 @@ STATIC const mp_obj_type_t mp_type_iobase; STATIC mp_obj_base_t iobase_singleton = {&mp_type_iobase}; -STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t iobase_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { (void)type; (void)n_args; - (void)n_kw; (void)args; + (void)kw_args; return MP_OBJ_FROM_PTR(&iobase_singleton); } @@ -113,8 +113,8 @@ typedef struct _mp_obj_bufwriter_t { byte buf[0]; } mp_obj_bufwriter_t; -STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, 2, false); +STATIC mp_obj_t bufwriter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 2, 2, false); size_t alloc = mp_obj_get_int(args[1]); mp_obj_bufwriter_t *o = m_new_obj_var(mp_obj_bufwriter_t, byte, alloc); o->base.type = type; diff --git a/py/objdeque.c b/py/objdeque.c index dd0141831..b2785b5b6 100644 --- a/py/objdeque.c +++ b/py/objdeque.c @@ -44,8 +44,8 @@ typedef struct _mp_obj_deque_t { #define FLAG_CHECK_OVERFLOW 1 } mp_obj_deque_t; -STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { - mp_arg_check_num(n_args, n_kw, 2, 3, false); +STATIC mp_obj_t deque_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { + mp_arg_check_num(n_args, kw_args, 2, 3, false); /* Initialization from existing sequence is not supported, so an empty tuple must be passed as such. */ diff --git a/py/objdict.c b/py/objdict.c index f672ac039..683fcb748 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -91,7 +91,10 @@ STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, const mp } #endif if (n_args > 0 || kw_args != NULL) { - mp_obj_t args2[2] = {dict_out, args[0]}; // args[0] is always valid, even if it's not a positional arg + mp_obj_t args2[2] = {dict_out, NULL}; // args[0] is always valid, even if it's not a positional arg + if (n_args > 0) { + args2[1] = args[0]; + } dict_update(n_args + 1, args2, kw_args); // dict_update will check that n_args + 1 == 1 or 2 } return dict_out; diff --git a/py/objfun.c b/py/objfun.c index 2ada0b3f1..b8364815b 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -436,7 +436,7 @@ typedef mp_uint_t (*viper_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t); STATIC mp_obj_t fun_viper_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_obj_fun_viper_t *self = self_in; - mp_arg_check_num(n_args, n_kw, self->n_args, self->n_args, false); + mp_arg_check_num_kw_array(n_args, n_kw, self->n_args, self->n_args, false); void *fun = MICROPY_MAKE_POINTER_CALLABLE(self->fun_data); diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c index 781a1871b..a044fe3ff 100644 --- a/py/objnamedtuple.c +++ b/py/objnamedtuple.c @@ -96,7 +96,10 @@ void namedtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) { const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t*)type_in; size_t num_fields = type->n_fields; - size_t n_kw = kw_args->used; + size_t n_kw = 0; + if (kw_args != NULL) { + n_kw = kw_args->used; + } if (n_args + n_kw != num_fields) { if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) { mp_arg_error_terse_mismatch(); |
