[pygobject] Fix leaked python reference in python-defined subclasses
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Fix leaked python reference in python-defined subclasses
- Date: Wed, 26 Jan 2011 20:47:39 +0000 (UTC)
commit 975341a26772966d4afc87a88a6a566d61237fa0
Author: Steve Frécinaux <code istique net>
Date: Fri Jan 21 18:41:54 2011 +0100
Fix leaked python reference in python-defined subclasses
https://bugzilla.gnome.org/show_bug.cgi?id=640184
gobject/gobjectmodule.c | 1 +
tests/test_gobject.py | 4 ++++
2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 13cf0f4..4ca092d 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -1048,6 +1048,7 @@ pygobject__g_instance_init(GTypeInstance *instance,
kwargs = PyDict_New();
if (Py_TYPE(wrapper)->tp_init(wrapper, args, kwargs))
PyErr_Print();
+ Py_DECREF(wrapper);
Py_DECREF(args);
Py_DECREF(kwargs);
pyglib_gil_state_release(state);
diff --git a/tests/test_gobject.py b/tests/test_gobject.py
index 19cc564..d628b0e 100644
--- a/tests/test_gobject.py
+++ b/tests/test_gobject.py
@@ -180,3 +180,7 @@ class TestPythonReferenceCounting(unittest.TestCase):
def testNewSubclassInstanceHasTwoRefs(self):
obj = A()
self.assertEquals(sys.getrefcount(obj), 2)
+
+ def testNewSubclassInstanceHasTwoRefsUsingGObjectNew(self):
+ obj = gobject.new(A)
+ self.assertEquals(sys.getrefcount(obj), 2)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]