Repository navigation
Wrong size of c_ulong/c_ulonglong in Linux #108907
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Sep 5, 2023 The ‘Standard size’ column refers to the size of the packed value in bytes when using standard size; that is, when the format string starts with one of '<', '>', '!' or '='. When using native size, the size of the packed value is platform-dependent.
_type_is apparently an attribute of each fundamental data type but unlikevalue, not of the base class_SimpleCData. Hence it is undocumented in this section. I think it should be, with a mention that the 'types' are 1 char strings from struct Format Characters(I am assuming this) -- with 'native' rather than 'standard' size implied. (I have no idea whether the above has always been true or if type is an addition.)_type_is only mentioned in Arrays and Pointers as "Specifies the type ..." with no indication as to what such specification consists of.Reacted by Ronald OussorenIMHO there is no bug here, other than the documentation issue mentioned by @terryjreedy.
c_ulongandc_ulonglongare documented as being representations of the C typesunsigned longandunsigned long long. As such they'll have the size of associated with those types. 64-bit Linux systems generally use a LP64 model whereunsigned longandunsigned long longare both 64-bit bit integers, and hencec_ulongandc_ulonglongare the same type. On 32-bit systemsunsigned longis generally a 32-bit quantity, and hencec_ulongandc_ulonglongwon't. be the same type there.Docs are updated.
the 'types' are 1 char strings from struct Format Characters(I am assuming this) -- with 'native' rather than 'standard' size implied. (I have no idea whether the above has always been true or if type is an addition.)
I've kept these -- and
array-- separate. There are some differences, but if you're reading about one individual module it's better to get the full table than “X but with Y rather than Z”.- added a commit that references this issue
on Mar 23, 2026
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Bug report
Bug description:
Attribute
_type_ofc_ulongreturnsL, which is correct following the format characters documentation; however, the documentation says it has 4 bytes size, butsizeof(c_ulong)returns 8 bytes.Also
c_ulonglongis automatically casted toc_ulong:, thus if
c_ulongwill have 4 bytes, will be there available a type of 8 bytes size?CPython versions tested on:
3.8
Operating systems tested on:
Linux
Linked PRs