mirror of
https://github.com/licsber/micropython.git
synced 2024-09-20 09:00:23 +08:00
moductypes: Make .sizeof() work with bytearrays.
This commit is contained in:
parent
66d08eb4fe
commit
8bb71f0b06
@ -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) {
|
STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) {
|
||||||
mp_uint_t max_field_size = 0;
|
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)
|
// We can apply sizeof either to structure definition (a dict)
|
||||||
// or to instantiated structure
|
// or to instantiated structure
|
||||||
if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) {
|
if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user