Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions py/obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,8 @@ typedef mp_obj_t (*mp_fun_kw_t)(size_t n, const mp_obj_t *, mp_map_t *);
#define MP_TYPE_FLAG_PRINT_JSON (0x0800)
// CIRCUITPY-CHANGE: gc_run_finalisers_first() runs this type's finaliser early in VM shutdown.
#define MP_TYPE_FLAG_FINALISER_FIRST (0x1000)
// CIRCUITPY-CHANGE: a native type that Python classes may not subclass.
#define MP_TYPE_FLAG_NOT_SUBCLASSABLE (0x2000)

typedef enum {
PRINT_STR = 0,
Expand Down
3 changes: 2 additions & 1 deletion py/objtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,8 @@ static mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals
}
mp_obj_type_t *t = MP_OBJ_TO_PTR(bases_items[i]);
// TODO: Verify with CPy, tested on function type
if (!MP_OBJ_TYPE_HAS_SLOT(t, make_new)) {
// CIRCUITPY-CHANGE: or a native type that is not subclassable
if (!MP_OBJ_TYPE_HAS_SLOT(t, make_new) || (t->flags & MP_TYPE_FLAG_NOT_SUBCLASSABLE)) {
#if MICROPY_ERROR_REPORTING <= MICROPY_ERROR_REPORTING_TERSE
mp_raise_TypeError(MP_ERROR_TEXT("type isn't an acceptable base type"));
#else
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ static MP_DEFINE_CONST_DICT(picogame_bitmap_locals_dict, picogame_bitmap_locals_
MP_DEFINE_CONST_OBJ_TYPE(
picogame_bitmap_type,
MP_QSTR_Bitmap,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_bitmap_make_new,
locals_dict, &picogame_bitmap_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Canvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ static MP_DEFINE_CONST_DICT(picogame_canvas_locals_dict, picogame_canvas_locals_
MP_DEFINE_CONST_OBJ_TYPE(
picogame_canvas_type,
MP_QSTR_Canvas,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_canvas_make_new,
locals_dict, &picogame_canvas_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Display.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ static MP_DEFINE_CONST_DICT(picogame_display_locals_dict, picogame_display_local
MP_DEFINE_CONST_OBJ_TYPE(
picogame_display_type,
MP_QSTR_Display,
MP_TYPE_FLAG_NONE,
MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_display_make_new,
locals_dict, &picogame_display_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static MP_DEFINE_CONST_DICT(picogame_framebuffer_locals_dict, picogame_framebuff
MP_DEFINE_CONST_OBJ_TYPE(
picogame_framebuffer_type,
MP_QSTR_Framebuffer,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_framebuffer_make_new,
locals_dict, &picogame_framebuffer_locals_dict
);
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Particles.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static MP_DEFINE_CONST_DICT(picogame_particles_locals_dict, picogame_particles_l
MP_DEFINE_CONST_OBJ_TYPE(
picogame_particles_type,
MP_QSTR_Particles,
MP_TYPE_FLAG_NONE,
MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_particles_make_new,
locals_dict, &picogame_particles_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Scene.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ static MP_DEFINE_CONST_DICT(picogame_scene_locals_dict, picogame_scene_locals_di
MP_DEFINE_CONST_OBJ_TYPE(
picogame_scene_type,
MP_QSTR_Scene,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_scene_make_new,
locals_dict, &picogame_scene_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Sprite.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ static MP_DEFINE_CONST_DICT(picogame_sprite_locals_dict, picogame_sprite_locals_
MP_DEFINE_CONST_OBJ_TYPE(
picogame_sprite_type,
MP_QSTR_Sprite,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_sprite_make_new,
locals_dict, &picogame_sprite_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/StripDraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static MP_DEFINE_CONST_DICT(picogame_stripdraw_locals_dict, picogame_stripdraw_l
MP_DEFINE_CONST_OBJ_TYPE(
picogame_stripdraw_type,
MP_QSTR_StripDraw,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_stripdraw_make_new,
locals_dict, &picogame_stripdraw_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Tilemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static MP_DEFINE_CONST_DICT(picogame_tilemap_locals_dict, picogame_tilemap_local
MP_DEFINE_CONST_OBJ_TYPE(
picogame_tilemap_type,
MP_QSTR_Tilemap,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_tilemap_make_new,
locals_dict, &picogame_tilemap_locals_dict
);
2 changes: 1 addition & 1 deletion shared-bindings/picogame/Triangles.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static MP_DEFINE_CONST_DICT(picogame_triangles_locals_dict, picogame_triangles_l
MP_DEFINE_CONST_OBJ_TYPE(
picogame_triangles_type,
MP_QSTR_Triangles,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS,
MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS | MP_TYPE_FLAG_NOT_SUBCLASSABLE,
make_new, picogame_triangles_make_new,
locals_dict, &picogame_triangles_locals_dict
);
4 changes: 2 additions & 2 deletions shared-bindings/picogame/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,10 +605,10 @@ static mp_obj_t pg_stub_make_new(const mp_obj_type_t *type, size_t n_args, size_
}
#endif
#if !CIRCUITPY_PICOGAME_FAST_DISPLAY
MP_DEFINE_CONST_OBJ_TYPE(picogame_display_type, MP_QSTR_Display, MP_TYPE_FLAG_NONE, make_new, pg_stub_make_new);
MP_DEFINE_CONST_OBJ_TYPE(picogame_display_type, MP_QSTR_Display, MP_TYPE_FLAG_NOT_SUBCLASSABLE, make_new, pg_stub_make_new);
#endif
#if !CIRCUITPY_PICOGAME_FRAMEBUFFER
MP_DEFINE_CONST_OBJ_TYPE(picogame_framebuffer_type, MP_QSTR_Framebuffer, MP_TYPE_FLAG_NONE, make_new, pg_stub_make_new);
MP_DEFINE_CONST_OBJ_TYPE(picogame_framebuffer_type, MP_QSTR_Framebuffer, MP_TYPE_FLAG_NOT_SUBCLASSABLE, make_new, pg_stub_make_new);
#endif

static const mp_rom_map_elem_t picogame_module_globals_table[] = {
Expand Down
Loading