Skip to content

Commit 8bb71f0

Browse files
committed
moductypes: Make .sizeof() work with bytearrays.
1 parent 66d08eb commit 8bb71f0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

extmod/moductypes.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, mp_uint_t *max_field_size
263263

264264
STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) {
265265
mp_uint_t max_field_size = 0;
266+
if (MP_OBJ_IS_TYPE(obj_in, &mp_type_bytearray)) {
267+
return mp_obj_len(obj_in);
268+
}
266269
// We can apply sizeof either to structure definition (a dict)
267270
// or to instantiated structure
268271
if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) {

0 commit comments

Comments
 (0)