[pygobject/pygobject-3-30] gtktemplate: only call the custom init hook if the class has it. Fixes #267



commit ae9380c4e5de529f5f3a3f3dd8a9e78411a0365c
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Nov 26 09:06:35 2018 +0100

    gtktemplate: only call the custom init hook if the class has it. Fixes #267

 gi/gimodule.c       | 2 +-
 tests/test_gdbus.py | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/gi/gimodule.c b/gi/gimodule.c
index 3a616165..e25583e5 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -1066,7 +1066,7 @@ pygobject__g_instance_init(GTypeInstance   *instance,
     }
 
     /* XXX: used for Gtk.Template */
-    if (PyObject_HasAttrString (wrapper, "__dontuse_ginstance_init__")) {
+    if (PyObject_HasAttrString ((PyObject*) Py_TYPE (wrapper), "__dontuse_ginstance_init__")) {
         result = PyObject_CallMethod (wrapper, "__dontuse_ginstance_init__", NULL);
         if (result == NULL)
             PyErr_Print ();
diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py
index 18315afa..6e38abe3 100644
--- a/tests/test_gdbus.py
+++ b/tests/test_gdbus.py
@@ -248,3 +248,10 @@ class TestGDBusClient(unittest.TestCase):
 
         self.assertTrue(isinstance(data['error'], Exception))
         self.assertTrue('InvalidArgs' in str(data['error']), str(data['error']))
+
+    def test_instantiate_custom_proxy(self):
+        class SomeProxy(Gio.DBusProxy):
+            def __init__(self):
+                Gio.DBusProxy.__init__(self)
+
+        SomeProxy()


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