After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730908 - Not calling GObject base initializer warns or crashes when invoking methods
Not calling GObject base initializer warns or crashes when invoking methods
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2014-05-29 02:07 UTC by Simon Feltman
Modified: 2017-03-31 06:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Raise RuntimeError in case an uninitilialized GObject.Object is marshaled (1.81 KB, patch)
2017-03-26 14:27 UTC, Christoph Reiter (lazka)
committed Details | Review

Description Simon Feltman 2014-05-29 02:07:51 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.
Comment 1 Christoph Reiter (lazka) 2017-03-26 14:27:22 UTC
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.