mirror of
https://github.com/micropython/micropython.git
synced 2025-09-06 09:50:20 +02:00
With this patch alignment is done relative to the start of the buffer that is being unpacked, not the raw pointer value, as per CPython. Fixes issue #3314.
18 lines
424 B
Python
18 lines
424 B
Python
# test ustruct and endian specific things
|
|
|
|
try:
|
|
import ustruct as struct
|
|
except:
|
|
try:
|
|
import struct
|
|
except ImportError:
|
|
print("SKIP")
|
|
raise SystemExit
|
|
|
|
# unpack/unpack_from with unaligned native type
|
|
buf = b'0123456789'
|
|
print(struct.unpack('h', memoryview(buf)[1:3]))
|
|
print(struct.unpack_from('i', buf, 1))
|
|
print(struct.unpack_from('@i', buf, 1))
|
|
print(struct.unpack_from('@ii', buf, 1))
|