summaryrefslogtreecommitdiffstatshomepage
path: root/py/objobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objobject.c')
-rw-r--r--py/objobject.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/py/objobject.c b/py/objobject.c
index 49d2ec62ee..265fcfbf2b 100644
--- a/py/objobject.c
+++ b/py/objobject.c
@@ -52,9 +52,12 @@ STATIC mp_obj_t object___new__(mp_obj_t cls) {
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("__new__ arg must be a user-type");
}
- mp_obj_t o = MP_OBJ_SENTINEL;
- mp_obj_t res = mp_obj_instance_make_new(MP_OBJ_TO_PTR(cls), 1, 0, &o);
- return res;
+ // This executes only "__new__" part of instance creation.
+ // TODO: This won't work well for classes with native bases.
+ // 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), &native_base));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___new___fun_obj, object___new__);
STATIC MP_DEFINE_CONST_STATICMETHOD_OBJ(object___new___obj, MP_ROM_PTR(&object___new___fun_obj));