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 641493 - subclass of gobject and introspected interface is broken
subclass of gobject and introspected interface is broken
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
Git master
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-02-04 14:11 UTC by Steve Frécinaux
Modified: 2011-02-04 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix subclasses of gobject.GObject and an introspected interface (1010 bytes, patch)
2011-02-04 14:15 UTC, Steve Frécinaux
none Details | Review
[GI] Fix vfunc search bug when using GInterfaces and a do_* method. (2.12 KB, patch)
2011-02-04 15:38 UTC, Laszlo Pandy
committed Details | Review

Description Steve Frécinaux 2011-02-04 14:11:10 UTC
I have one failing test in libpeas' python support:

  /extension/python/create-valid:                                      Traceback (most recent call last):
  • File "/home/sf/src/gnome2/libpeas/tests/libpeas/plugins/extension-python/extension-python.py", line 22 in <module>
    class PropertiesPythonPlugin(gobject.GObject, Introspection.Properties):
  • File "/opt/gnome2/lib/python2.6/site-packages/gi/types.py", line 217 in __init__
    cls._setup_vfuncs()
  • File "/opt/gnome2/lib/python2.6/site-packages/gi/types.py", line 133 in _setup_vfuncs
    vfunc_info = find_vfunc_info_in_interface(cls.__bases__, vfunc_name[len("do_"):])
  • File "/opt/gnome2/lib/python2.6/site-packages/gi/types.py", line 182 in find_vfunc_info_in_interface
    vfunc = find_vfunc_info_in_interface(base.__bases__, vfunc_name)
  • File "/opt/gnome2/lib/python2.6/site-packages/gi/types.py", line 175 in find_vfunc_info_in_interface
    not isinstance(base.__info__, InterfaceInfo):
AttributeError: type object 'gobject.GInterface' has no attribute '__info__'

This is the code:

class PropertiesPythonPlugin(gobject.GObject, Introspection.Properties):
    __gtype_name__ = "PropertiesPythonPlugin"

    construct_only = gobject.property(type=str, #default="construct-only",
                                      flags=(gobject.PARAM_READWRITE |
                                             gobject.PARAM_CONSTRUCT_ONLY))

    read_only = gobject.property(type=str, #default="read-only",
                                 flags=gobject.PARAM_READABLE)

    write_only = gobject.property(type=str, #default="write-only",
                                  flags=(gobject.PARAM_WRITABLE |
                                         gobject.PARAM_CONSTRUCT))

    readwrite = gobject.property(type=str, #default="readwrite",
                                 flags=(gobject.PARAM_READWRITE |
                                        gobject.PARAM_CONSTRUCT))

After investigating a bit, the cause of this exception is that gobject.GObject has no __info__ attribute, and the metaclass assumes all the bases have that attribute. It could be fixed by adding a check if the '__info__' attribute exists.

This might be breaking all the static bindings subclasses out there.
Comment 1 Steve Frécinaux 2011-02-04 14:15:50 UTC
Created attachment 180081 [details] [review]
Fix subclasses of gobject.GObject and an introspected interface

An exception was raised because gobject.GObject doesn't have a __info__
class member.
Comment 2 Steve Frécinaux 2011-02-04 14:29:58 UTC
Looks like I was actually misreading the checks. The issue is that Introspection.Properties is an introspected interface but doesn't have the __info__ field. gobject.GObject should not be an issue since it's not an interface so it's ruled out by the issubclass(base, gobject.GInterface) test.
Comment 3 Laszlo Pandy 2011-02-04 15:38:53 UTC
Created attachment 180087 [details] [review]
[GI] Fix vfunc search bug when using GInterfaces and a do_* method.

If a class inherits from a GInterface, as well as implements a do_*
method (which is not in a super class), all the base interfaces
will be searched for an __info__ attribute. GInterface doesn't
have one, causing an error on class creation.
Comment 4 Steve Frécinaux 2011-02-04 15:50:20 UTC
Fixed in master. Thanks!