[pygi] Only hookup vfunc implementations for locally-defined methods
- From: Tomeu Vizoso <tomeuv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygi] Only hookup vfunc implementations for locally-defined methods
- Date: Wed, 5 May 2010 05:40:11 +0000 (UTC)
commit 5e20c018ae09a936f5ff140df5d1c133c98e98ba
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date: Thu Apr 29 13:09:03 2010 +0200
Only hookup vfunc implementations for locally-defined methods
https://bugzilla.gnome.org/show_bug.cgi?id=617160
gi/types.py | 10 +++++++++-
tests/test_gi.py | 10 ++++++++++
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gi/types.py b/gi/types.py
index 78b126d..23c44ea 100644
--- a/gi/types.py
+++ b/gi/types.py
@@ -104,10 +104,18 @@ class MetaClassHelper(object):
'the method do_%s()' % (base.__info__.get_namespace(),
base.__info__.get_name(),
vfunc_info.get_name()))
- elif vfunc is not None:
+ elif vfunc is not None and not \
+ is_function_in_classes(vfunc.im_func, cls.__bases__):
hook_up_vfunc_implementation(vfunc_info, cls.__gtype__,
vfunc)
+def is_function_in_classes(function, classes):
+ for klass in classes:
+ if function in klass.__dict__.values():
+ return True
+ elif is_function_in_classes(function, klass.__bases__):
+ return True
+ return False
class GObjectMeta(gobject.GObjectMeta, MetaClassHelper):
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 2c596be..3db562d 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1476,6 +1476,16 @@ class TestInterfaces(unittest.TestCase):
GIMarshallingTests.test_interface_test_int8_in(instance, 42)
self.assertEquals(instance.val, 42)
+ class TestInterfaceImplA(TestInterfaceImpl):
+ __gtype_name__ = 'TestInterfaceImplA'
+
+ class TestInterfaceImplB(TestInterfaceImplA):
+ __gtype_name__ = 'TestInterfaceImplB'
+
+ instance = TestInterfaceImplA()
+ GIMarshallingTests.test_interface_test_int8_in(instance, 42)
+ self.assertEquals(instance.val, 42)
+
class TestOverrides(unittest.TestCase):
def test_constant(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]