summaryrefslogtreecommitdiff
path: root/shared-bindings/displayio/TileGrid.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-05-13 17:31:30 -0700
committerScott Shawcroft <scott@tannewt.org>2019-05-13 17:31:30 -0700
commitf29de5132562cd6e88661d150fa1ee3ab8b771e1 (patch)
tree1f3ac8c4779e4badc825d22fac3c38aceb5bb99e /shared-bindings/displayio/TileGrid.c
parenta6785d7ff74e156c5bcfdd8f46b1cccae41cc3bf (diff)
Check native object in case of early access
If a native displayio object is accessed before it's super().__init__() has been called, then a placeholder is given that will cause a crash if accessed. This is tricky to get right so we detect this case and raise a NotInplementedError instead of crashing. Fixes #1881
Diffstat (limited to 'shared-bindings/displayio/TileGrid.c')
-rw-r--r--shared-bindings/displayio/TileGrid.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/shared-bindings/displayio/TileGrid.c b/shared-bindings/displayio/TileGrid.c
index 2b41eb8fd..6d18ac78f 100644
--- a/shared-bindings/displayio/TileGrid.c
+++ b/shared-bindings/displayio/TileGrid.c
@@ -31,6 +31,7 @@
#include "lib/utils/context_manager_helpers.h"
#include "py/binary.h"
#include "py/objproperty.h"
+#include "py/objtype.h"
#include "py/runtime.h"
#include "shared-bindings/displayio/Bitmap.h"
#include "shared-bindings/displayio/ColorConverter.h"
@@ -139,6 +140,7 @@ STATIC mp_obj_t displayio_tilegrid_make_new(const mp_obj_type_t *type, size_t n_
// Helper to ensure we have the native super class instead of a subclass.
static displayio_tilegrid_t* native_tilegrid(mp_obj_t tilegrid_obj) {
mp_obj_t native_tilegrid = mp_instance_cast_to_native_base(tilegrid_obj, &displayio_tilegrid_type);
+ mp_obj_assert_native_inited(native_tilegrid);
return MP_OBJ_TO_PTR(native_tilegrid);
}