From 8bb71f0b06cb558b76471bd5459c1ca49224d2cc Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 30 Oct 2014 03:48:50 +0200 Subject: [PATCH] moductypes: Make .sizeof() work with bytearrays. --- extmod/moductypes.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extmod/moductypes.c b/extmod/moductypes.c index 006bcb80d6..dc3776f9a6 100644 --- a/extmod/moductypes.c +++ b/extmod/moductypes.c @@ -263,6 +263,9 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, mp_uint_t *max_field_size STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) { mp_uint_t max_field_size = 0; + if (MP_OBJ_IS_TYPE(obj_in, &mp_type_bytearray)) { + return mp_obj_len(obj_in); + } // We can apply sizeof either to structure definition (a dict) // or to instantiated structure if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) {