summaryrefslogtreecommitdiffstats
path: root/patches/0004-Create-instances-by-calling-tp_alloc-rather-than-PyO.patch
blob: 44f0c46ad33c876331735bdd75e98d4dc48e59d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 44378cd12b9ffb9a323bc529403266c27baad1a5 Mon Sep 17 00:00:00 2001
From: Simon van der Linden <svdlinden@src.gnome.org>
Date: Sat, 7 Nov 2009 23:42:07 +0100
Subject: [PATCH 4/4] 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 b9cf6b3..220bf27 100644
--- a/gobject/pygboxed.c
+++ b/gobject/pygboxed.c
@@ -198,7 +198,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);
-- 
1.6.3.3