diff mbox

[3/8] python: use Py_TYPE instead of looking directly into PyObject_HEAD

Message ID 1487846908-21462-4-git-send-email-marmarek@invisiblethingslab.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marek Marczykowski-Górecki Feb. 23, 2017, 10:48 a.m. UTC
Py_TYPE works on both Python2 and Python3, while internals of
PyObject_HEAD have changed.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
---
 tools/python/xen/lowlevel/xc/xc.c | 2 +-
 tools/python/xen/lowlevel/xs/xs.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index 109ef57..75842ef 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -2670,7 +2670,7 @@  static void PyXc_dealloc(XcObject *self)
         self->xc_handle = NULL;
     }
 
-    self->ob_type->tp_free((PyObject *)self);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static PyTypeObject PyXcType = {
diff --git a/tools/python/xen/lowlevel/xs/xs.c b/tools/python/xen/lowlevel/xs/xs.c
index e9eef73..74a80ca 100644
--- a/tools/python/xen/lowlevel/xs/xs.c
+++ b/tools/python/xen/lowlevel/xs/xs.c
@@ -922,7 +922,7 @@  static void xshandle_dealloc(XsHandle *self)
 
     Py_XDECREF(self->watches);
 
-    self->ob_type->tp_free((PyObject *)self);
+    Py_TYPE(self)->tp_free((PyObject *)self);
 }
 
 static PyTypeObject xshandle_type = {