fix circuitpy memoryview.cast

This commit is contained in:
Jeff Epler 2023-09-22 13:43:58 -05:00
parent 0d796249e8
commit bb0f8149df
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 8 additions and 4 deletions

View File

@ -396,8 +396,10 @@ static mp_obj_t generatorexit(void) {
#if MICROPY_CPYTHON_EXCEPTION_CHAIN #if MICROPY_CPYTHON_EXCEPTION_CHAIN
MP_STATIC_ASSERT(!MICROPY_CONST_GENERATOREXIT_OBJ); MP_STATIC_ASSERT(!MICROPY_CONST_GENERATOREXIT_OBJ);
mp_obj_exception_initialize0(&mp_static_GeneratorExit_obj, &mp_type_GeneratorExit); mp_obj_exception_initialize0(&mp_static_GeneratorExit_obj, &mp_type_GeneratorExit);
#endif return MP_OBJ_FROM_PTR(&mp_static_GeneratorExit_obj);
#else
return MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj); return MP_OBJ_FROM_PTR(&mp_const_GeneratorExit_obj);
#endif
} }
STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) { STATIC mp_obj_t gen_instance_close(mp_obj_t self_in) {

View File

@ -2040,7 +2040,7 @@ mp_obj_t mp_obj_bytes_fromhex(mp_obj_t type_in, mp_obj_t data) {
STATIC mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) { STATIC mp_obj_t bytes_hex_as_str(size_t n_args, const mp_obj_t *args) {
return mp_obj_bytes_hex(n_args, args, &mp_type_str); return mp_obj_bytes_hex(n_args, args, &mp_type_str);
} }
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_obj_bytes_hex_as_str_obj, 1, 2, bytes_hex_as_str);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex); STATIC MP_DEFINE_CONST_FUN_OBJ_2(bytes_fromhex_obj, mp_obj_bytes_fromhex);
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj)); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bytes_fromhex_classmethod_obj, MP_ROM_PTR(&bytes_fromhex_obj));
@ -2073,7 +2073,7 @@ STATIC const mp_rom_map_elem_t array_bytearray_str_bytes_locals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&mp_obj_array_extend_obj) }, { MP_ROM_QSTR(MP_QSTR_extend), MP_ROM_PTR(&mp_obj_array_extend_obj) },
#endif #endif
#if MICROPY_PY_BUILTINS_BYTES_HEX #if MICROPY_PY_BUILTINS_BYTES_HEX
{ MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&bytes_hex_as_str_obj) }, { MP_ROM_QSTR(MP_QSTR_hex), MP_ROM_PTR(&mp_obj_bytes_hex_as_str_obj) },
{ MP_ROM_QSTR(MP_QSTR_fromhex), MP_ROM_PTR(&bytes_fromhex_classmethod_obj) }, { MP_ROM_QSTR(MP_QSTR_fromhex), MP_ROM_PTR(&bytes_fromhex_classmethod_obj) },
#endif #endif
#if MICROPY_CPYTHON_COMPAT #if MICROPY_CPYTHON_COMPAT
@ -2160,7 +2160,8 @@ MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_array_locals_dict,
TABLE_ENTRIES_ARRAY); TABLE_ENTRIES_ARRAY);
#endif #endif
#if MICROPY_PY_BUILTINS_MEMORYVIEW && MICROPY_PY_BUILTINS_BYTES_HEX // CIRCUITPY: hex() but no cast()
#if MICROPY_PY_BUILTINS_MEMORYVIEW && MICROPY_PY_BUILTINS_BYTES_HEX && !MICROPY_CPYTHON_COMPAT
MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict, MP_DEFINE_CONST_DICT_WITH_SIZE(mp_obj_memoryview_locals_dict,
array_bytearray_str_bytes_locals_table + TABLE_ENTRIES_ARRAY, array_bytearray_str_bytes_locals_table + TABLE_ENTRIES_ARRAY,
1); // Just the "hex" entry. 1); // Just the "hex" entry.

View File

@ -119,5 +119,6 @@ extern const mp_obj_dict_t mp_obj_array_locals_dict;
// CIRCUITPY // CIRCUITPY
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj); MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(bytes_decode_obj);
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mp_obj_bytes_hex_as_str_obj);
#endif // MICROPY_INCLUDED_PY_OBJSTR_H #endif // MICROPY_INCLUDED_PY_OBJSTR_H