GNOME Bugzilla – Bug 685197
Need to support (in) GError arguments
Last modified: 2016-03-02 05:14:08 UTC
Method taking a (const GError *) as argument can't currently be used in Pythonn as python-gobject see those as exceptions. void tp_handle_channels_context_fail (TpHandleChannelsContext *self, const GError *error); http://telepathy.freedesktop.org/doc/telepathy-glib/telepathy-glib-handle-channels-context.html#tp-handle-channels-context-fail
Right now, gobject-introspection skips GError arguments completely in the "standard" case of passing a GError* which points to a NULL GError*. So in pygobject we could tell apart these two by looking at the type. If you build the annotations for your project with that method, what does the .gir for this method look like?
<method name="fail" c:identifier="tp_handle_channels_context_fail" version="0.11.6"> <doc xml:whitespace="preserve">Called by #TpBaseClientClassAddDispatchOperationImpl to raise a D-Bus error.</doc> <return-value transfer-ownership="none"> <type name="none" c:type="void"/> </return-value> <parameters> <parameter name="error" transfer-ownership="none"> <doc xml:whitespace="preserve">the error to return from the method</doc> <type name="GLib.Error" c:type="const GError*"/> </parameter> </parameters> </method>
That looks fine. So I guess we should be able to handle that on the pygobject side in principle.
Relevant places to fix this: https://git.gnome.org/browse/pygobject/tree/gi/pygi-marshal-from-py.c?id=3.9.5#n1177 and: https://git.gnome.org/browse/pygobject/tree/gi/pygi-argument.c?id=3.9.5#n1243 These should also share a unified marshaling function placed in pygi-marshal-from-py.c
I experienced a bit of deja vu while writing that last comment. Sure enough I wrote almost the exact same thing in bug #616036 *** This bug has been marked as a duplicate of bug 616036 ***
Re-opening as this as bug 616036 is not exactly the same use case. bug 616036 is referring to callbacks.
*** Bug 755916 has been marked as a duplicate of this bug. ***
*** Bug 757323 has been marked as a duplicate of this bug. ***
Created attachment 322625 [details] [review] gerror: Add "_to_py" suffix to pygi_error_marshal
Created attachment 322626 [details] [review] gerror: Add support for marshaling GError from Python to C I'd love to get this in for 3.20, so reviews welcome.
I've verified this also fixes the use cases in bug 755916 and bug 757323.
Review of attachment 322625 [details] [review]: lgtm
Review of attachment 322626 [details] [review]: lgtm
Review of attachment 322625 [details] [review]: Committed: https://git.gnome.org/browse/pygobject/commit/?id=2fc1a689a816
Review of attachment 322626 [details] [review]: Committed: https://git.gnome.org/browse/pygobject/commit/?id=cfca1457c3