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 690904 - GObject Introspection should support marking error-indicating booleans
GObject Introspection should support marking error-indicating booleans
Status: RESOLVED DUPLICATE of bug 649657
Product: gobject-introspection
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gobject-introspection Maintainer(s)
gobject-introspection Maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2012-12-30 21:13 UTC by lamefun
Modified: 2015-02-07 17:03 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description lamefun 2012-12-30 21:13:12 UTC
For example, gboolean g_file_load_contents (GFile *file, GCancellable *cancellable, char **contents, int *length, char **etag_out, GError **error).

In Python, it's used as:

>>> from gi.repository import Gio
>>> f = Gio.File.new_for_path('README')
>>> f.load_contents(None)
(True, 'Hello, World!', '1356891983:529356')

The True boolean at the beginning of the tuple is useless: when g_file_load_contents returns FALSE, it also sets error and Python code will never get to process the return value.
Comment 1 Philip Withnall 2012-12-30 23:31:34 UTC
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find.

*** This bug has been marked as a duplicate of bug 649657 ***
Comment 2 Simon Feltman 2013-01-01 01:01:23 UTC
Based on the ticket this was duplicated as (bug 649657) perhaps this should stay open and be re-titled as a ticket specific to function the OP is complaining about? The fix would simply be to add a "skip" annotation to the boolean return of load_contents.
Comment 3 Dan Winship 2013-01-02 18:31:21 UTC
The problem is that that would be an ABI break; existing code that was doing:

  success, contents, etag = f.load_contents(None)

would suddenly start getting "ValueError: need more than 2 values to unpack"

We're trying to make sure it gets used appropriately on new APIs, but we can't add it to existing ones.
Comment 4 André Klapper 2015-02-07 17:03:04 UTC
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]