Commit 1d9c6b6d authored by Tomeu Vizoso's avatar Tomeu Vizoso
Browse files

Dont force subclasses to implement all virtual methods of their bases

https://bugzilla.gnome.org/show_bug.cgi?id=616674
parent 8a0c48f4
......@@ -99,12 +99,12 @@ class MetaClassHelper(object):
continue
for vfunc_info in base.__info__.get_vfuncs():
vfunc = getattr(cls, 'do_' + vfunc_info.get_name(), None)
if vfunc is None:
if vfunc is None and isinstance(base.__info__, InterfaceInfo):
raise TypeError('Class implementing %s.%s should implement '
'the method do_%s()' % (base.__info__.get_namespace(),
base.__info__.get_name(),
vfunc_info.get_name()))
else:
elif vfunc is not None:
hook_up_vfunc_implementation(vfunc_info, cls.__gtype__,
vfunc)
......
......@@ -1409,6 +1409,9 @@ class TestPythonGObject(unittest.TestCase):
def do_method_int8_in(self, int8):
self.val = int8
def do_method_with_default_implementation(self, int8):
self.props.int = int8 * 2
def test_object(self):
self.assertTrue(issubclass(self.Object, GIMarshallingTests.Object))
......@@ -1423,6 +1426,18 @@ class TestPythonGObject(unittest.TestCase):
object_.method_int8_in(84)
self.assertEqual(object_.val, 84)
object_.method_with_default_implementation(42)
self.assertEqual(object_.val, 84)
class ObjectWithoutVFunc(GIMarshallingTests.Object):
__gtype_name__ = 'ObjectWithoutVFunc'
def __init__(self, int):
GIMarshallingTests.Object.__init__(self)
object_ = ObjectWithoutVFunc(int = 42)
object_.method_with_default_implementation(84)
self.assertEqual(object_.props.int, 84)
class TestMultiOutputArgs(unittest.TestCase):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment