[New-bugs-announce] [issue3547] Ctypes is confused by bitfields of varying integer types
Tim Maxwell
report at bugs.python.org
Tue Aug 12 18:20:18 CEST 2008
New submission from Tim Maxwell <timmaxw at gmail.com>:
Steps to reproduce:
Python 2.5.2 (r252:60911, Feb 22 2008, 07:57:53)
[GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import *
>>> fields = [('a', c_short, 4), ('b', c_short, 4), ('c', c_long, 24)]
>>> class Foo(Structure):
... _fields_ = fields
...
>>> Foo.a
<Field type=c_short, ofs=0:0, bits=4>
>>> Foo.b
<Field type=c_short, ofs=0:4, bits=4>
>>> Foo.c
<Field type=c_long, ofs=-2:8, bits=24> # Wrong!
More about my machine:
>>> sizeof(c_short)
2
>>> sizeof(c_long)
4
This particular example comes from a 32-bit Mac OS X Intel machine. The
bug has been reproduced on Linux as well, but could not be reproduced on
Windows XP.
----------
assignee: theller
components: ctypes
messages: 71060
nosy: theller, tim.maxwell
severity: normal
status: open
title: Ctypes is confused by bitfields of varying integer types
type: behavior
versions: Python 2.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3547>
_______________________________________
More information about the New-bugs-announce
mailing list