This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Charles Machalow
Recipients Charles Machalow
Date 2015-12-14.02:52:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1450061530.03.0.0248609360686.issue25858@psf.upfronthosting.co.za>
In-reply-to
Content
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.

class bugStruct(Structure):
    _pack_ = 1
    _fields_ = [
                ("correct", c_uint8 * 65535),
                ("wrongSizeAndOffset", c_uint8 * 999999),
               ]

print(str(bugStruct.correct))
<Field type=c_ubyte_Array_65535, ofs=0, size=65535> # Correct

print(str(bugStruct.wrongSizeAndOffset))
<Field type=c_ubyte_Array_999999, ofs=65535:16959, bits=15> # Incorrect
# Should be: <Field type=c_ubyte_Array_999999, ofs=65535, size=999999>

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
History
Date User Action Args
2015-12-14 02:52:10Charles Machalowsetrecipients: + Charles Machalow
2015-12-14 02:52:10Charles Machalowsetmessageid: <1450061530.03.0.0248609360686.issue25858@psf.upfronthosting.co.za>
2015-12-14 02:52:09Charles Machalowlinkissue25858 messages
2015-12-14 02:52:09Charles Machalowcreate