Python 3: use Py_TYPE() instead of ob_type member
authorNils Philippsen <nils@tiptoe.de>
Wed, 25 Nov 2015 23:38:48 +0000 (00:38 +0100)
committerNils Philippsen <nils@tiptoe.de>
Thu, 26 Nov 2015 13:48:03 +0000 (14:48 +0100)
python/ext/aubio-types.h
python/ext/aubiowraphell.h
python/ext/py-cvec.c
python/ext/py-filter.c

index 280d01b..c206a8b 100644 (file)
 #define AUBIO_NPY_SMPL NPY_FLOAT
 #endif
 
+// compat with Python < 2.6
+#ifndef Py_TYPE
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
+#endif
+
 // special python type for cvec
 typedef struct
 {
index d60cc30..b9146ef 100644 (file)
@@ -25,7 +25,7 @@ static void \
 Py_ ## NAME ## _del ( Py_ ## NAME * self) \
 { \
   del_aubio_ ## NAME (self->o); \
-  self->ob_type->tp_free ((PyObject *) self); \
+  Py_TYPE(self)->tp_free ((PyObject *) self); \
 }
 
 #define AUBIO_MEMBERS_START(NAME) \
index 940508f..a060696 100644 (file)
@@ -59,7 +59,7 @@ static void
 Py_cvec_del (Py_cvec * self)
 {
   del_cvec (self->o);
-  self->ob_type->tp_free ((PyObject *) self);
+  Py_TYPE(self)->tp_free ((PyObject *) self);
 }
 
 static PyObject *
index 416bba8..ad508be 100644 (file)
@@ -55,7 +55,7 @@ static void
 Py_filter_del (Py_filter * self)
 {
   del_aubio_filter (self->o);
-  self->ob_type->tp_free ((PyObject *) self);
+  Py_TYPE(self)->tp_free ((PyObject *) self);
 }
 
 static PyObject *