Skip to content

Commit 0876034

Browse files
committed
Make decode only apply to bytearray and not array as well
1 parent fe3e8ee commit 0876034

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

py/objarray.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
551551
}
552552

553553

554-
#if MICROPY_CPYTHON_COMPAT
554+
#if MICROPY_CPYTHON_COMPAT && MICROPY_PY_BUILTINS_BYTEARRAY
555555
// Directly lifted from objstr.c
556556
STATIC mp_obj_t array_decode(size_t n_args, const mp_obj_t *args) {
557557
mp_obj_t new_args[2];
@@ -567,18 +567,28 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(array_decode_obj, 1, 3, array_decode);
567567
#endif
568568

569569

570-
#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
570+
#if MICROPY_PY_ARRAY
571571
STATIC const mp_rom_map_elem_t array_locals_dict_table[] = {
572572
{ MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) },
573573
{ MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) },
574+
};
575+
576+
STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table);
577+
#endif
578+
579+
#if MICROPY_PY_BUILTINS_BYTEARRAY
580+
STATIC const mp_rom_map_elem_t bytearray_locals_dict_table[] = {
581+
{ MP_ROM_QSTR(MP_QSTR_append), MP_ROM_PTR(&array_append_obj) },
582+
{ MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&array_extend_obj) },
574583
#if MICROPY_CPYTHON_COMPAT
575584
{ MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&array_decode_obj) },
576585
#endif
577586
};
578587

579-
STATIC MP_DEFINE_CONST_DICT(array_locals_dict, array_locals_dict_table);
588+
STATIC MP_DEFINE_CONST_DICT(bytearray_locals_dict, bytearray_locals_dict_table);
580589
#endif
581590

591+
582592
#if MICROPY_PY_ARRAY
583593
const mp_obj_type_t mp_type_array = {
584594
{ &mp_type_type },
@@ -605,7 +615,7 @@ const mp_obj_type_t mp_type_bytearray = {
605615
.binary_op = array_binary_op,
606616
.subscr = array_subscr,
607617
.buffer_p = { .get_buffer = array_get_buffer },
608-
.locals_dict = (mp_obj_dict_t*)&array_locals_dict,
618+
.locals_dict = (mp_obj_dict_t*)&bytearray_locals_dict,
609619
};
610620
#endif
611621

0 commit comments

Comments
 (0)