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
uctypes: assign to scalar in an array is not fully implemented
import uctypes
desc = {
# arr is array at offset 0, of UINT32 elements, array size is 2
"arr": (uctypes.ARRAY | 0, uctypes.UINT32 | 2),
}
data = bytearray(8)
s = uctypes.struct(uctypes.addressof(data), desc)
s.arr[0] = 0x11223344
gives TypeError: 'struct' object does not support item assignment
It only works for UINT8 (because the array comes out as a bytearray).
I've got a patch+test for this, but #1698 mention I big refactor coming.
Are you interested in it anyway ?