GNOME Bugzilla – Bug 749680
super() is not called
Last modified: 2018-01-10 20:49:42 UTC
My test case is: #!/usr/bin/env python from gi.repository import Gtk class Super(object): def __init__(self): print("Super here") super(Super, self).__init__() class Side(Super): def __init__(self): print("Side here") super(Side, self).__init__() #class Child(Side, Gtk.Window): class Child(Gtk.Window, Side): def __init__(self): print("Child here") super(Child, self).__init__() Super() print('-----') Side() print('-----') Child() I have expected that Side's constructor is called as well as Super's. If I take care of the order of the base classes, then it works, but I didn't expect having to do that. I didn't understand bug 315079, bug 351566 nor bug 710646, so this might very well be a duplicate. Although I am missing a concise test case and in my example.
A similar thing can be seen with the list built-in type: class Foo(object): def __init__(self, *args, **kwargs): print("Foo") super(Foo, self).__init__(*args, **kwargs) class A(list, Foo): def __init__(self, *args, **kwargs): print("A") super(A, self).__init__(*args, **kwargs) A() ----------- It's because tp_init doesn't chain up using super. Here is an example: https://pythonextensionpatterns.readthedocs.io/en/latest/super_call.html It might be easier to override __init__ for GObject.Object and call super in Python (super(gi._gobject.GObject, self)...)
There also exists a python bug regarding the list behavior https://bugs.python.org/issue8733
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/100.