[New-bugs-announce] [issue26746] struct.pack(): trailing padding bytes on x64
Stefan Krah
report at bugs.python.org
Wed Apr 13 04:38:49 EDT 2016
New submission from Stefan Krah:
On the x64 architecture gcc adds trailing padding bytes after the last
struct member. NumPy does the same:
>>> import numpy as np
>>>
>>> t = np.dtype([('x', 'u1'), ('y', 'u8'), ('z', 'u1')], align=True)
>>> x = np.array([(1, 2, 3)], dtype=t)
>>> x.tostring()
b'\x01\xf7\xba\xab\x03\x7f\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00'
The struct module in native mode does not:
>>> struct.pack("BQB", 1, 2, 3)
b'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x03'
I'm not sure if this is intended -- or if full compatibility to
native compilers is even achievable in the general case.
----------
components: Extension Modules
messages: 263315
nosy: mark.dickinson, skrah
priority: normal
severity: normal
status: open
title: struct.pack(): trailing padding bytes on x64
type: behavior
versions: Python 3.6
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26746>
_______________________________________
More information about the New-bugs-announce
mailing list