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 655051 - Gio.DBusConnection.register_object() expects an extra argument (proably the GDestroyNotify)
Gio.DBusConnection.register_object() expects an extra argument (proably the G...
Status: RESOLVED DUPLICATE of bug 656325
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-07-21 14:19 UTC by Martin Pitt
Modified: 2013-09-12 07:51 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Martin Pitt 2011-07-21 14:19:37 UTC
I'm once again trying to port some python-dbus stuff over to GDBus with GI. The part where this currently fails is registering an object on the Bus:

$ python -c "from gi.repository import Gio; con=Gio.bus_get_sync(Gio.BusType.SESSION, None); con.register_object('/org/gtk/Test', Gio.DBusInterfaceInfo(), None, 'my_data')"
Traceback (most recent call last):
  • File "<string>", line 1 in <module>
  • File "gi/types.py", line 44 in function
    return info.invoke(*args)
TypeError: register_object() takes exactly 6 argument(s) (5 given)

Now, I don't understand where the 6th argument comes from. The C API 

  http://developer.gnome.org/gio/2.29/GDBusConnection.html#g-dbus-connection-register-object

has the GDestroyNotify as 6th argument, and the GError** as 7th, both of which are usually provided internally by pygobject. The corresponding GIR from this:

        <parameters>
          <parameter name="object_path" transfer-ownership="none">
            <doc xml:whitespace="preserve">The object path to register at.</doc>
            <type name="utf8" c:type="gchar*"/>
          </parameter>
          <parameter name="interface_info" transfer-ownership="none">
            <doc xml:whitespace="preserve">Introspection data for the interface.</doc>
            <type name="DBusInterfaceInfo" c:type="GDBusInterfaceInfo*"/>
          </parameter>
          <parameter name="vtable" transfer-ownership="none" allow-none="1">
            <doc xml:whitespace="preserve">A #GDBusInterfaceVTable to call into or %NULL.</doc>
            <type name="DBusInterfaceVTable" c:type="GDBusInterfaceVTable*"/>
          </parameter>
          <parameter name="user_data" transfer-ownership="none">
            <doc xml:whitespace="preserve">Data to pass to functions in @vtable.</doc>
            <type name="gpointer" c:type="gpointer"/>
          </parameter>
          <parameter name="user_data_free_func"
                     transfer-ownership="none"
                     scope="async">
            <doc xml:whitespace="preserve">Function to call when the object path is unregistered.</doc>
            <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
          </parameter>
        </parameters>

There are two odd things here:

 * The GError isn't specified at all. Other methods in /usr/share/gir-1.0/Gio-2.0.gir do specify this. Is this a bug in g-i?

 * The GDestroyNotify seems to be right. Many methods in Gio's GIR declare it as allow-none="1", a lot of others don't. Which one is right here?

Trying to supply an extra None doesn't work:

python -c "from gi.repository import Gio; con=Gio.bus_get_sync(Gio.BusType.SESSION, None); con.register_object('/org/gtk/Test', Gio.DBusInterfaceInfo(), None, 'my_data', None)"

But specifying a bogus GDestroyNotify seems to "work":

python -c "from gi.repository import Gio; con=Gio.bus_get_sync(Gio.BusType.SESSION, None); con.register_object('/org/gtk/Test', Gio.DBusInterfaceInfo(), None, 'my_data', lambda *x: None)" 

(process:7712): GLib-GIO-CRITICAL **: g_dbus_is_interface_name: assertion `string != NULL' failed

(process:7712): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion `g_dbus_is_interface_name (interface_info->name)' failed

(These warnings seem justified, as the passed InterfaceInfo() is bogus)

So it seems pygobject doesn't properly see the GDestroyNotify here?

Note that this isn't related to the invoke-rewrite branch. It happens just as well in 2.28, or earlier master versions.
Comment 1 Martin Pitt 2012-04-22 14:24:36 UTC
Confirmed on 3.2.0.
Comment 2 Simon Feltman 2013-09-12 03:33:44 UTC
This basically looks like annotation problems or even lack of supporting GDestroyNotify without a general callback it is used with. Normally there will be a callback argument which specifies:
closure="<argnum>" # userdata index
destroy="<argnum>" # destroy notify index

This is what PyGObject uses to automatically manage DestroyNotify arguments. So this is definitally an odd case to work with. We might try annotating the DestroyNotify arg with (closure user_data) and (allow-none) and see if it makes things any more useable.
Comment 3 Simon Feltman 2013-09-12 07:51:18 UTC
After reading through bug 656325, it looks like that should solve all the problems related to the bindability of g_dbus_connection_register_object.

*** This bug has been marked as a duplicate of bug 656325 ***