GNOME Bugzilla – Bug 656872
gio load_contents_finished return values changed
Last modified: 2012-04-20 13:09:00 UTC
The old static bindings for gio.File.load_contents_finish() returned: gio.File.load_contents_finish def load_contents_finish(result) result : a gio.AsyncResult. Returns : a three tuple containing the contents of the file, the length of the contents of the file and the current entity tag for the file. With the new bindings it: (success, content, etag(?)) - it would be nice to consider consistency with the old bindings.
I assume "new bindings" are with PyGI? gboolean g_file_load_contents_finish (GFile *file, GAsyncResult *res, char **contents, gsize *length, char **etag_out, GError **error); This is supposed to return (return-bool, contents, etag), as the annotation already maps the "length" out argument to the length of contents; in language bindings the length field is rather uninteresting? I think the questionable bit here is not the length out value, but the "success" flag. We had some similar cases where out values were undefined and using them caused crashes when the functions returned FALSE, e. g. in Gdk.color_parse(): http://git.gnome.org/browse/pygobject/commit/?id=5b1c875 Gtk.TextIter: http://git.gnome.org/browse/pygobject/commit/?id=fc5c869486c7f In these cases we added an override to only return the out values on success==True, otherwise return None. Do we need this here as well, i. e. are the returned values undefined when the function returns False?
*** This bug has been marked as a duplicate of bug 620912 ***