py/objobject: object___new__: Take any args and pass them down to constructor.
@@ -48,7 +48,9 @@ STATIC mp_obj_t object___init__(mp_obj_t self) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
-STATIC mp_obj_t object___new__(mp_obj_t cls) {
+STATIC mp_obj_t object___new__(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+ size_t n_kw = kwargs->used;
+ mp_obj_t cls = args[0];
if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
mp_raise_TypeError(MP_ERROR_TEXT("arg must be user-type"));
}
@@ -57,9 +59,9 @@ STATIC mp_obj_t object___new__(mp_obj_t cls) {
// TODO: This is a hack, should be resolved along the lines of
// https://github.com/micropython/micropython/issues/606#issuecomment-43685883
const mp_obj_type_t *native_base;
- return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), 0, 0, NULL, &native_base));
+ return MP_OBJ_FROM_PTR(mp_obj_new_instance(MP_OBJ_TO_PTR(cls), n_args - 1, n_kw, args + 1, &native_base));
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
+STATIC MP_DEFINE_CONST_FUN_OBJ_KW(object___new___fun_obj, 1, object___new__);
STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));
#if MICROPY_PY_DELATTR_SETATTR
