GNOME Bugzilla – Bug 690904
GObject Introspection should support marking error-indicating booleans
Last modified: 2015-02-07 17:03:04 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.
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 ***
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.
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.
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]