You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Structure field size/ofs __str__ wrong with large size fields #70045
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2015-12-14.02:52:09.933>labels= ['ctypes', 'type-bug', '3.8', '3.9', '3.10']
title='Structure field size/ofs __str__ wrong with large size fields'updated_at=<Date2020-11-08.18:15:58.491>user='https://bugs.python.org/CharlesMachalow'
Large sized fields in Structures lead to incorrect string representations because it is assuming that because the size is so large, it must be a bit field instead of a byte field.
To get the math for this do the following on an incorrect size/offset:
size = (bits << 16) + ofs.split(":")[1]
ofs = ofs.split(":")[0]
Though this isn't really safe because the field may actually be bit-sized
Activity
CharlesMachalow commentedon Dec 14, 2015
Large sized fields in Structures lead to incorrect string representations because it is assuming that because the size is so large, it must be a bit field instead of a byte field.
To get the math for this do the following on an incorrect size/offset:
size = (bits << 16) + ofs.split(":")[1]
ofs = ofs.split(":")[0]
Though this isn't really safe because the field may actually be bit-sized
CharlesMachalow commentedon Dec 14, 2015
Adding file with code to reproduce.
encukou commentedon May 13, 2025
Fixed in #97702: [edit: fixed number]