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 644260 - DBusProxyMethodCall.__call__ should not require a signature for methods without arguments
DBusProxyMethodCall.__call__ should not require a signature for methods witho...
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: gio
Git master
Other Linux
: Normal normal
: ---
Assigned To: martin.pitt
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-03-09 00:09 UTC by Max Prohorov
Modified: 2011-03-15 09:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow None signature (601 bytes, patch)
2011-03-09 00:09 UTC, Max Prohorov
none Details | Review

Description Max Prohorov 2011-03-09 00:09:27 UTC
Created attachment 182898 [details] [review]
Allow None signature

Calling DBusProxyMethodCall object with none arguments results in such error:
Traceback (most recent call last):
  • File "gdbus_check.py", line 10 in <module>
    result = proxy.PurpleGetConversations(None) # Fails
  • File "/home/mcs/.local/lib64/python3.2/site-packages/gi/overrides/Gio.py", line 123 in __call__
    arg_variant = GLib.Variant(signature, tuple(args))
  • File "/home/mcs/.local/lib64/python3.2/site-packages/gi/overrides/GLib.py", line 181 in __new__
    (v, rest_format, _) = creator._create(format_string, [value])
  • File "/home/mcs/.local/lib64/python3.2/site-packages/gi/overrides/GLib.py", line 74 in _create
    constructor = self._LEAF_CONSTRUCTORS.get(format[0])
TypeError: 'NoneType' object is not subscriptable

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
Comment 1 Max Prohorov 2011-03-09 14:35:18 UTC
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],)
Comment 2 johnp 2011-03-10 03:18:27 UTC
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.
Comment 3 Martin Pitt 2011-03-15 08:10:56 UTC
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.