GNOME Bugzilla – Bug 730908
Not calling GObject base initializer warns or crashes when invoking methods
Last modified: 2017-03-31 06:01:03 UTC
The problem is GObject.Object.__init__ is what ends up creating the backing GObject so when this is not call, the held GObject pointer will be NULL: from gi.repository import GObject class Spam(GObject.Object): def __init__(self): pass # super __init__ is not called. spam = Spam() spam.notify('eggs') Warning: g_object_notify: assertion 'G_IS_OBJECT (object)' failed #!/usr/bin/python3 We should raise an exception if a method is called and the GObject pointer for "self" is NULL.
Created attachment 348739 [details] [review] Raise RuntimeError in case an uninitilialized GObject.Object is marshaled One common case where this can happen is when subclassing a GObject.Object without chaining up __init__ and then calling a method.