[pygobject] Fix vfunc search bug when using GInterfaces and a do_* method.



commit 8dad0eaed60a9de26e9a729a48a1f6bc74be486e
Author: Laszlo Pandy <lpandy src gnome org>
Date:   Fri Feb 4 16:36:07 2011 +0100

    Fix vfunc search bug when using GInterfaces and a do_* method.
    
    If a class inherits from a GInterface, as well as implements a do_*
    method (which is not in a super class), all the base interfaces
    will be searched for an __info__ attribute. GInterface doesn't
    have one, causing an error on class creation.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=641493

 gi/types.py      |    4 +++-
 tests/test_gi.py |    8 ++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gi/types.py b/gi/types.py
index a7a4569..37cf499 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -171,7 +171,9 @@ def find_vfunc_info_in_interface(bases, vfunc_name):
         # All wrapped interfaces inherit from GInterface.
         # This can be seen in IntrospectionModule.__getattr__() in module.py.
         # We do not need to search regular classes here, only wrapped interfaces.
-        if not issubclass(base, gobject.GInterface) or\
+        # We also skip GInterface, because it is not wrapped and has no __info__ attr.
+        if base is gobject.GInterface or\
+                not issubclass(base, gobject.GInterface) or\
                 not isinstance(base.__info__, InterfaceInfo):
             continue
 
diff --git a/tests/test_gi.py b/tests/test_gi.py
index eede8ff..22ff2c4 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1466,6 +1466,14 @@ class TestPythonGObject(unittest.TestCase):
             
         self.assertTrue(func1 is func2)
 
+    def test_subobject_with_interface_and_non_vfunc_do_method(self):
+        # There was a bug for searching for vfuncs in interfaces. It was
+        # triggered by having a do_* method that wasn't overriding
+        # a native vfunc, as well as inheriting from an interface.
+        class GObjectSubclassWithInterface(GObject.GObject, GIMarshallingTests.Interface):
+            def do_method_not_a_vfunc(self):
+                pass
+
 class TestMultiOutputArgs(unittest.TestCase):
 
     def test_int_out_out(self):



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