py/objarray: Disallow memoryview addition.
Following CPython. This is important for subsequent commits to work correctly. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
9accb7dd44
commit
ca9068e0ef
@ -292,6 +292,12 @@ STATIC mp_obj_t array_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
|
|||||||
mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
|
mp_obj_array_t *lhs = MP_OBJ_TO_PTR(lhs_in);
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case MP_BINARY_OP_ADD: {
|
case MP_BINARY_OP_ADD: {
|
||||||
|
#if MICROPY_PY_BUILTINS_MEMORYVIEW
|
||||||
|
if (lhs->base.type == &mp_type_memoryview) {
|
||||||
|
return MP_OBJ_NULL; // op not supported
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// allow to add anything that has the buffer protocol (extension to CPython)
|
// allow to add anything that has the buffer protocol (extension to CPython)
|
||||||
mp_buffer_info_t lhs_bufinfo;
|
mp_buffer_info_t lhs_bufinfo;
|
||||||
mp_buffer_info_t rhs_bufinfo;
|
mp_buffer_info_t rhs_bufinfo;
|
||||||
|
@ -6,8 +6,18 @@ except:
|
|||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
# unsupported binary operators
|
# unsupported binary operators
|
||||||
|
try:
|
||||||
|
memoryview(b"") + b""
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
||||||
|
|
||||||
|
try:
|
||||||
|
memoryview(b"") + memoryview(b"")
|
||||||
|
except TypeError:
|
||||||
|
print("TypeError")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
m = memoryview(bytearray())
|
m = memoryview(bytearray())
|
||||||
m += bytearray()
|
m += bytearray()
|
||||||
except TypeError:
|
except TypeError:
|
||||||
print('TypeError')
|
print("TypeError")
|
||||||
|
Loading…
Reference in New Issue
Block a user