py/modstruct: Fix struct.pack_into with unaligned offset of native type.

Following the same fix for unpack.
This commit is contained in:
Damien George
2019-09-02 12:57:51 +10:00
parent 1022f9cc35
commit 24c3e9b283
5 changed files with 14 additions and 6 deletions

View File

@@ -15,3 +15,10 @@ 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))
# pack_into with unaligned native type
buf = bytearray(b'>----<<<<<<<')
struct.pack_into('i', buf, 1, 0x30313233)
print(buf)
struct.pack_into('@ii', buf, 3, 0x34353637, 0x41424344)
print(buf)