summaryrefslogtreecommitdiff
path: root/py/objarray.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2021-07-13 18:01:12 +1000
committerJim Mussared <jim.mussared@gmail.com>2022-08-12 12:44:30 +1000
commit28aaab95909aab092cc8c16188fec157142f18a9 (patch)
tree7792fc4fa68f9641da91fac41e824b78e17c2273 /py/objarray.c
parent6c67fbc280625c59fff7cdf93f16d5e2ad0bad8a (diff)
py/objstr: Add hex/fromhex to bytes/memoryview/bytearray.
These were added in Python 3.5. Enabled via MICROPY_PY_BUILTINS_BYTES_HEX, and enabled by default for all ports that currently have ubinascii. Rework ubinascii to use the implementation of these methods. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'py/objarray.c')
-rw-r--r--py/objarray.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/py/objarray.c b/py/objarray.c
index 11bd7bb15..ecaffeb6a 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -245,6 +245,12 @@ STATIC void memoryview_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
mp_obj_array_t *self = MP_OBJ_TO_PTR(self_in);
dest[0] = MP_OBJ_NEW_SMALL_INT(mp_binary_get_size('@', self->typecode & TYPECODE_MASK, NULL));
}
+ #if MICROPY_PY_BUILTINS_BYTES_HEX
+ else {
+ // Need to forward to locals dict.
+ dest[1] = MP_OBJ_SENTINEL;
+ }
+ #endif
}
#endif
@@ -607,6 +613,9 @@ const mp_obj_type_t mp_type_memoryview = {
#if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
.attr = memoryview_attr,
#endif
+ #if MICROPY_PY_BUILTINS_BYTES_HEX
+ .locals_dict = (mp_obj_dict_t *)&mp_obj_memoryview_locals_dict,
+ #endif
.subscr = array_subscr,
.buffer_p = { .get_buffer = array_get_buffer },
};