pviktori / rpms / aubio

Forked from rpms/aubio 4 years ago
Clone
a5a57d3
From 16e3209e730152f78a794256a24fd69d215dabf1 Mon Sep 17 00:00:00 2001
a5a57d3
From: Nils Philippsen <nils@redhat.com>
a5a57d3
Date: Thu, 26 Nov 2015 00:38:48 +0100
a5a57d3
Subject: [PATCH 4/6] Python 3: use Py_TYPE() instead of ob_type member
a5a57d3
a5a57d3
---
a5a57d3
 python/ext/aubio-types.h   | 5 +++++
a5a57d3
 python/ext/aubiowraphell.h | 2 +-
a5a57d3
 python/ext/py-cvec.c       | 2 +-
a5a57d3
 python/ext/py-filter.c     | 2 +-
a5a57d3
 4 files changed, 8 insertions(+), 3 deletions(-)
a5a57d3
a5a57d3
diff --git a/python/ext/aubio-types.h b/python/ext/aubio-types.h
a5a57d3
index 280d01b..c206a8b 100644
a5a57d3
--- a/python/ext/aubio-types.h
a5a57d3
+++ b/python/ext/aubio-types.h
a5a57d3
@@ -39,6 +39,11 @@
a5a57d3
 #define AUBIO_NPY_SMPL NPY_FLOAT
a5a57d3
 #endif
a5a57d3
 
a5a57d3
+// compat with Python < 2.6
a5a57d3
+#ifndef Py_TYPE
a5a57d3
+#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
a5a57d3
+#endif
a5a57d3
+
a5a57d3
 // special python type for cvec
a5a57d3
 typedef struct
a5a57d3
 {
a5a57d3
diff --git a/python/ext/aubiowraphell.h b/python/ext/aubiowraphell.h
a5a57d3
index d60cc30..b9146ef 100644
a5a57d3
--- a/python/ext/aubiowraphell.h
a5a57d3
+++ b/python/ext/aubiowraphell.h
a5a57d3
@@ -25,7 +25,7 @@ static void \
a5a57d3
 Py_ ## NAME ## _del ( Py_ ## NAME * self) \
a5a57d3
 { \
a5a57d3
   del_aubio_ ## NAME (self->o); \
a5a57d3
-  self->ob_type->tp_free ((PyObject *) self); \
a5a57d3
+  Py_TYPE(self)->tp_free ((PyObject *) self); \
a5a57d3
 }
a5a57d3
 
a5a57d3
 #define AUBIO_MEMBERS_START(NAME) \
a5a57d3
diff --git a/python/ext/py-cvec.c b/python/ext/py-cvec.c
a5a57d3
index 940508f..a060696 100644
a5a57d3
--- a/python/ext/py-cvec.c
a5a57d3
+++ b/python/ext/py-cvec.c
a5a57d3
@@ -59,7 +59,7 @@ static void
a5a57d3
 Py_cvec_del (Py_cvec * self)
a5a57d3
 {
a5a57d3
   del_cvec (self->o);
a5a57d3
-  self->ob_type->tp_free ((PyObject *) self);
a5a57d3
+  Py_TYPE(self)->tp_free ((PyObject *) self);
a5a57d3
 }
a5a57d3
 
a5a57d3
 static PyObject *
a5a57d3
diff --git a/python/ext/py-filter.c b/python/ext/py-filter.c
a5a57d3
index 416bba8..ad508be 100644
a5a57d3
--- a/python/ext/py-filter.c
a5a57d3
+++ b/python/ext/py-filter.c
a5a57d3
@@ -55,7 +55,7 @@ static void
a5a57d3
 Py_filter_del (Py_filter * self)
a5a57d3
 {
a5a57d3
   del_aubio_filter (self->o);
a5a57d3
-  self->ob_type->tp_free ((PyObject *) self);
a5a57d3
+  Py_TYPE(self)->tp_free ((PyObject *) self);
a5a57d3
 }
a5a57d3
 
a5a57d3
 static PyObject * 
a5a57d3
-- 
a5a57d3
2.5.0
a5a57d3