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 Pavel.Boldin
Recipients Pavel.Boldin
Date 2011-09-09.13:54:48
SpamBayes Score 0.00017475721
Marked as misclassified No
Message-id <1315576489.44.0.807779711581.issue12945@psf.upfronthosting.co.za>
In-reply-to
Content
ctypes seems to work incorrectly with _swappedbytes_ specified.

I.e. it misses some values from buffer:

class X(ctypes.Structure):
    _swappedbytes_ = 1
    _pack_ = 1
    _fields_ = [
        ('a', ctypes.c_ubyte, 4),
        ('b', ctypes.c_ubyte, 4),
        ('c', ctypes.c_ushort, 8),
        ('d', ctypes.c_ushort, 8),
    ]

buf = '\x12\x34\x56\x78'
x = X.from_buffer_copy(buf)

print x.a == 1
print x.b == 2
print x.c == 3
print x.d == 4

This prints
True
True
False
False

Where as four 'True' are expected.
History
Date User Action Args
2011-09-09 13:54:49Pavel.Boldinsetrecipients: + Pavel.Boldin
2011-09-09 13:54:49Pavel.Boldinsetmessageid: <1315576489.44.0.807779711581.issue12945@psf.upfronthosting.co.za>
2011-09-09 13:54:48Pavel.Boldinlinkissue12945 messages
2011-09-09 13:54:48Pavel.Boldincreate