[issue15119] ctypes mixed-types bitfield layout nonsensical; doesn't match compiler.
Olaf Hartmann
report at bugs.python.org
Wed Jul 16 20:52:42 CEST 2014
Olaf Hartmann added the comment:
I just run into this issue, so i'll bump it with another test case:
import ctypes
class Struct(ctypes.Structure):
_fields_ = [
("uint8_0", ctypes.c_uint8, 8),
("uint8_1", ctypes.c_uint8, 8),
("uint16_0", ctypes.c_uint16, 1),
("uint16_1", ctypes.c_uint16, 15),
]
for f in Struct._fields_:
print f[0], getattr(Struct, f[0])
> python bitfield.py
uint8_0 <Field type=c_ubyte, ofs=0:0, bits=8>
uint8_1 <Field type=c_ubyte, ofs=1:0, bits=8>
uint16_0 <Field type=c_ushort, ofs=1:8, bits=1>
uint16_1 <Field type=c_ushort, ofs=4:0, bits=15>
Originally tested with Python 2.7.3, but also confirmed with later versions.
Is there any workaround by specifying ofs and bits manually?
----------
nosy: +wbu
versions: +Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15119>
_______________________________________
More information about the Python-bugs-list
mailing list