mirror of
https://github.com/python/cpython.git
synced 2025-08-19 00:00:48 +00:00
Fix issue #3547: ctypes is confused by bitfields of varying integer types
Reviewed by Fredrik Lundh and Skip Montanaro. Backport from trunk.
This commit is contained in:
parent
a7a94a0a21
commit
8e97ea9c6b
3 changed files with 19 additions and 1 deletions
|
@ -215,6 +215,21 @@ class BitFieldTest(unittest.TestCase):
|
|||
("b", c_ubyte, 4)]
|
||||
self.failUnlessEqual(sizeof(X), sizeof(c_byte))
|
||||
|
||||
def test_mixed_4(self):
|
||||
class X(Structure):
|
||||
_fields_ = [("a", c_short, 4),
|
||||
("b", c_short, 4),
|
||||
("c", c_int, 24),
|
||||
("d", c_short, 4),
|
||||
("e", c_short, 4),
|
||||
("f", c_int, 24)]
|
||||
# MS compilers do NOT combine c_short and c_int into
|
||||
# one field, gcc does.
|
||||
if os.name in ("nt", "ce"):
|
||||
self.failUnlessEqual(sizeof(X), sizeof(c_int) * 4)
|
||||
else:
|
||||
self.failUnlessEqual(sizeof(X), sizeof(c_int) * 2)
|
||||
|
||||
def test_anon_bitfields(self):
|
||||
# anonymous bit-fields gave a strange error message
|
||||
class X(Structure):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue