On Wed, March 20, 2013 7:31 pm, Christoph Kuhr wrote: > Hi everyone, > > I was trying to build the alsaaudio/pyalsa module for Python 3. > I converted the Python sources with 2to3, afterwards gcc fails to build > the module pyalsacontrol.c: > > pyalsa/alsacontrol.c:184:6: error: ?struct pyalsacontrol? has no member > named ?ob_type? > > I could not not find any definition of "ob_type". > > Has anyone solved this problem? > Probably not. The struct is defined at line 54. http://python3porting.com/cextensions.html ++++ Another change in the object header is that the PyObject_HEAD macro has changed so that ob_type is now in a nested structure. This means you no longer can pick the ob_type directly from the struct, so code like ob->ob_type stops working. You should replace this with Py_TYPE(ob). The Py_TYPE macro doesn?t appear until Python 2.6, so to support earlier versions we make another #ifndef: #ifndef Py_TYPE #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #endif In both cases the definitions above are taken directly from the Python 2.6 headers, where they are defined for forward compatibility purposes with Python 3. They work well in earlier Python versions as well, so this is a trick you can use as a general rule; if you need to use a macro that is defined in Python 3 and Python 2.6, just steal the Python 2.6 or Python 2.7 definition and put it inside an #ifndef. ++++ You should be able to add the following above line 54 and it will compile. #ifndef Py_TYPE #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) #endif -- Patrick Shirkey Boost Hardware Ltd _______________________________________________ Linux-audio-user mailing list Linux-audio-user@xxxxxxxxxxxxxxxxxxxx http://lists.linuxaudio.org/listinfo/linux-audio-user