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, amaury.forgeotdarc, belopolsky, meador.inge
Date 2017-03-08.00:36:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1488933400.56.0.160685455632.issue29753@psf.upfronthosting.co.za>
In-reply-to
Content
There appears to be a bug related to sizing/packing of ctypes Structures on Linux. I'm not quite sure how, but this structure:

class MyStructure(Structure):
    _pack_      = 1
    _fields_    = [ 
                      ("P",       c_uint16),    # 2 Bytes
                      ("L",       c_uint16, 9),
                      ("Pro",     c_uint16, 1),
                      ("G",       c_uint16, 1),
                      ("IB",      c_uint16, 1),
                      ("IR",      c_uint16, 1),
                      ("R",       c_uint16, 3), # 4 Bytes
                      ("T",       c_uint32, 10),
                      ("C",       c_uint32, 20),
                      ("R2",      c_uint32, 2)  # 8 Bytes
                  ]

Gives back a sizeof of 8 on Windows and 10 on Linux. The inconsistency makes it difficult to have code work cross-platform.

Running the given test.py file will print out the size of the structure on your platform.

Tested with Python 2.7.6 and Python 3.4.3 (builtin to Ubuntu 14.04), Python 2.7.13, (built from source) both on Ubuntu 14.04. On Linux all Python builds were 32 bit.

On Windows I tried with 2.7.7 (both 32 and 64 bit).

I believe on both platforms it should return a sizeof 8.
History
Date User Action Args
2017-03-08 00:36:40Charles Machalowsetrecipients: + Charles Machalow, amaury.forgeotdarc, belopolsky, meador.inge
2017-03-08 00:36:40Charles Machalowsetmessageid: <1488933400.56.0.160685455632.issue29753@psf.upfronthosting.co.za>
2017-03-08 00:36:40Charles Machalowlinkissue29753 messages
2017-03-08 00:36:40Charles Machalowcreate