Skip to content

Commit 08dd04e

Browse files
committed
Fix incorrect error message for ctypes bitfield overflow.
The previous message did not match the actual overflow check and omitted the bitfield size, making it misleading. Update the message to reflect the correct condition and report all relevant values. Signed-off-by: Yongtao Huang <yongtaoh2022@gmail.com>
1 parent cf6758f commit 08dd04e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Modules/_ctypes/cfield.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@ PyCField_new_impl(PyTypeObject *type, PyObject *name, PyObject *proto,
160160
if ((bitfield_size + bit_offset) > byte_size * 8) {
161161
PyErr_Format(
162162
PyExc_ValueError,
163-
"bit field %R overflows its type (%zd + %zd >= %zd)",
164-
name, bit_offset, byte_size*8);
163+
"bit field %R overflows its type (%zd + %zd > %zd)",
164+
name, bit_offset, bitfield_size, byte_size * 8);
165165
goto error;
166166
}
167167
}

0 commit comments

Comments
 (0)