ctypes inheritance issue

Steve steve.f.thompson at gmail.com
Tue Feb 22 18:13:09 EST 2011

I've filed a bug in python but I wanted to see if other ctypes users/
experts viewed this issue as a bug.
Consider the following:
python code:
import ctypes
class my_array( ctypes.Array ):
    _type_    = ctypes.c_uint8
    _length_  = 256

class my_array2( my_array ):

class my_array2( my_array ):
AttributeError: class must define a '_length_' attribute, which must
be a positive integer

This is analogous to the C code
typedef char my_array[ 256 ];
typedef my_array my_array2;

As shown above, the python code raises exceptions claiming _type_ and
_length_ have not been defined.  This seems like a bug.  I shouldn't
need to redefine _type_ and _length_, otherwise there was no point in
subclassing from my_array.


More information about the Python-list mailing list