QUERY · ISSUE
bytearray slice assignment fails for derived types
docs
The type check for slice assignment to bytearray derived types seems to be a bit too strict:
class MyBytearray(bytearray): pass
a = MyBytearray(4)
b = MyBytearray(4)
a[0:4] = b
results in this error:
Traceback (most recent call last):
File "test.py", line 5, in <module>
NotImplementedError: array/bytes required on right side
CANDIDATE · ISSUE
Bytearray slice assignement throwing exception on ESP32 idf v4.
Following the example in the documentation:
https://docs.micropython.org/en/latest/genrst/builtin_types.html#bytearray
>>> b = bytearray(4)
>>> b[0:1] = [1, 2]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError: array/bytes required on right
>>> print(b)
bytearray(b'\x00\x00\x00\x00')
I noticed that assigning b'\x01\x02' works.