[pygobject] Create instances by calling tp_alloc rather than PyObject_NEW



commit 6a69288941e65312fe82649ec72d2f21b2dc618f
Author: Simon van der Linden <svdlinden src gnome org>
Date:   Sat Nov 7 23:42:07 2009 +0100

    Create instances by calling tp_alloc rather than PyObject_NEW
    
    PyObject_NEW calls a generic allocator and should only be called by tp_new, knowing
    that the type's free function agrees. In pyg_boxed_new, we may allocate
    PyGBoxed subtypes, so the subtype's allocation function must be called instead.

 gobject/pygboxed.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
---
diff --git a/gobject/pygboxed.c b/gobject/pygboxed.c
index 8a4c8a8..1233b01 100644
--- a/gobject/pygboxed.c
+++ b/gobject/pygboxed.c
@@ -194,7 +194,8 @@ pyg_boxed_new(GType boxed_type, gpointer boxed, gboolean copy_boxed,
 
     if (!tp)
 	tp = (PyTypeObject *)&PyGBoxed_Type; /* fallback */
-    self = PyObject_NEW(PyGBoxed, tp);
+
+    self = (PyGBoxed *)tp->tp_alloc(tp, 0);
 
     if (self == NULL) {
 	pyglib_gil_state_release(state);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]