From 770b9e745c48b68ffb3f274adee0d14d52274868 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Thu, 26 Nov 2015 00:38:48 +0100 Subject: [PATCH] Python 3: use Py_TYPE() instead of ob_type member --- python/ext/aubio-types.h | 5 +++++ python/ext/aubiowraphell.h | 2 +- python/ext/py-cvec.c | 2 +- python/ext/py-filter.c | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/python/ext/aubio-types.h b/python/ext/aubio-types.h index 280d01b7..c206a8bd 100644 --- a/python/ext/aubio-types.h +++ b/python/ext/aubio-types.h @@ -39,6 +39,11 @@ #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 { diff --git a/python/ext/aubiowraphell.h b/python/ext/aubiowraphell.h index d60cc30a..b9146ef9 100644 --- a/python/ext/aubiowraphell.h +++ b/python/ext/aubiowraphell.h @@ -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) \ diff --git a/python/ext/py-cvec.c b/python/ext/py-cvec.c index 940508fb..a0606968 100644 --- a/python/ext/py-cvec.c +++ b/python/ext/py-cvec.c @@ -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 * diff --git a/python/ext/py-filter.c b/python/ext/py-filter.c index 416bba83..ad508be9 100644 --- a/python/ext/py-filter.c +++ b/python/ext/py-filter.c @@ -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 * -- 2.11.0