GNOME Bugzilla – Bug 655051
Gio.DBusConnection.register_object() expects an extra argument (proably the GDestroyNotify)
Last modified: 2013-09-12 07:51:18 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):
+ Trace 227832
return info.invoke(*args)
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.
Confirmed on 3.2.0.
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.
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 ***