GNOME Bugzilla – Bug 644260
DBusProxyMethodCall.__call__ should not require a signature for methods without arguments
Last modified: 2011-03-15 09:29:04 UTC
Created attachment 182898 [details] [review] Allow None signature Calling DBusProxyMethodCall object with none arguments results in such error: Traceback (most recent call last):
+ Trace 226236
result = proxy.PurpleGetConversations(None) # Fails
arg_variant = GLib.Variant(signature, tuple(args))
(v, rest_format, _) = creator._create(format_string, [value])
constructor = self._LEAF_CONSTRUCTORS.get(format[0])
Of course proxy.call_sync('method', None,...) is ok. Not sure if it is intended or not. Probably its going to be replaced by some signature generator? Suggested change for current to Gio.py attached
First, congratulations on stable release :) Looks like I've missed that '()' signature will result in GVariant('()', ()) and will produce no arguments as expected. Anyway this looks a bit strange comparing to the old dbus-python, and to C counterpart. Could be any other methow with no args. Pidgin's PurpleGetConversations require no arguments and returns 'ai' ... GError *error; GVariant *value; gchar *v_str; value = g_dbus_proxy_call_sync(proxy, "PurpleGetConversations", NULL, G_DBUS_PROXY_FLAGS_NONE, -1, NULL, &error); v_str = g_variant_print(value, TRUE); printf("%s\n", v_str); ... $ ./prog ([17547],)
I'll have Martin look at this but we are requiring signatures for the GDBus bindings. There is no automated retrieving of introspection data like there is in python-dbus. That is not to say someone can't go and write a library above it to do the nice things that dbus-python did. We should most likely take None to mean there are no arguments in the signature.
We discussed that yesterday on IRC. The canonical form for this is method('()'), but for methods with no arguments there is little reason to not make method() behave the same way instead of crashing. However, explicitly specifying a "None" signature does not make sense IMHO. Every D-BUS method has a signature, and an empty one '()' is not the same as no signature. The error message could be more friendly, though, I'll improve that.
Fixed in master: http://git.gnome.org/browse/pygobject/commit/?id=029a79d1af1e0998aa6bc88ce1c1f48ce0ccd2a0 Also cherrypicked into pygobject-2-28 branch: http://git.gnome.org/browse/pygobject/commit/?h=pygobject-2-28&id=115c4750f071270b648218c9678931a65a4b3e3d Thanks!