Skip to content

Commit 3042d03

Browse files
committed
Add test case
1 parent 862451b commit 3042d03

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Lib/test/test_ctypes/test_struct_fields.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,21 @@ class S(Structure):
130130
self.check_struct(S)
131131
self.assertEqual(S.largeField.bit_size, size * 8)
132132

133+
def test_bitfield_overflow_error_message_gh143164(self):
134+
with self.assertRaisesRegex(
135+
ValueError,
136+
r"bit field 'x' overflows its type \(0 \+ 9 > 8\)",
137+
):
138+
CField(
139+
name="x",
140+
type=c_byte,
141+
byte_size=1,
142+
byte_offset=0,
143+
index=0,
144+
_internal_use=True,
145+
bit_size=9,
146+
bit_offset=0,
147+
)
133148

134149
# __set__ and __get__ should raise a TypeError in case their self
135150
# argument is not a ctype instance.

0 commit comments

Comments
 (0)