Commit 66d08eb4 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

moductypes: Add test for accessing UINT8 array.

parent 6d287a6a
import uctypes
desc = {
"arr": (uctypes.ARRAY | 0, uctypes.UINT8 | 2),
"arr2": (uctypes.ARRAY | 2, uctypes.INT8 | 2),
}
data = bytearray(b"01234567")
S = uctypes.struct(desc, uctypes.addressof(data), uctypes.LITTLE_ENDIAN)
# Arrays of UINT8 are accessed as bytearrays
print(S.arr)
# But not INT8, because value range is different
print(type(S.arr2))
bytearray(b'01')
<class 'struct'>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment