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 ocean-city
Recipients higstar, ned.deily, ocean-city, r.david.murray, stutzbach, theller
Date 2010-10-03.16:34:28
SpamBayes Score 1.2302621e-09
Marked as misclassified No
Message-id <1286123671.7.0.877925324078.issue6493@psf.upfronthosting.co.za>
In-reply-to
Content
Here is at least better, simple patch. But ideally,
mask should be created from variable type. "short" mask
should be created for "short" variable, "long long" mask
for "long long" variable, vise verse.

I'll create such patch next. I hope it's final solution.

////////////////////////////////////////
// This works on attached patch.

from __future__ import print_function
import ctypes
class Blah(ctypes.Structure):
    _fields_ = [("a", ctypes.c_uint64, 64),
                ("b", ctypes.c_uint16, 16),
                ("c", ctypes.c_uint8, 8),
                ("d", ctypes.c_uint8, 8)]

x = Blah(0xFEDCBA9876543210,0xBEEF,0x44,0x12)
print(Blah.a, hex(x.a))
print(Blah.b, hex(x.b))
print(Blah.c, hex(x.c))
print(Blah.d, hex(x.d))
History
Date User Action Args
2010-10-03 16:34:31ocean-citysetrecipients: + ocean-city, theller, ned.deily, stutzbach, r.david.murray, higstar
2010-10-03 16:34:31ocean-citysetmessageid: <1286123671.7.0.877925324078.issue6493@psf.upfronthosting.co.za>
2010-10-03 16:34:29ocean-citylinkissue6493 messages
2010-10-03 16:34:29ocean-citycreate