GNOME Bugzilla – Bug 666098
gerrors need to be marshalled (needed by GStreamer bindings)
Last modified: 2012-01-24 14:53:46 UTC
+ Trace 229266
err, debug = message.parse_error()
return info.invoke(*args, **kwargs)
Re-assigning to python introspection as not a GStreamer issue
The code triggering this issue is: def BusWatcher(self): bus = self.pipeline.get_bus() bus.add_signal_watch() bus.connect('message', self.on_message) def on_message(self, bus, message): mtype = message.type # print mtype if mtype == Gst.MessageType.ERROR: print "we got an error, life is shit" err, debug = message.parse_error() print err print debug
Moving to glib/introspection after suggestion in #pygtk
We hide gerror implementation details since they should be thrown by interfaces but I can see the need to interact with them in an async context. Someone just needs to go ahead and implement marshalling for them where. Shouldn't be hard but I don't have any time these days to work on it. There should be an internal function we use to convert GErrors to pyobjects. That needs to be added to the place in the code where we throw the NotImplementedError.
Should be in pygi_marshal_to_py.c but in that case we also want to cover pygi_marshal_from_py.
moving to pygobject
Created attachment 205716 [details] [review] tests: add test functions which return GErrors GStreamer has the following method: void gst_message_parse_error ( GstMessage *message, GError **error, gchar **debug_message); This patch adds a number of test functions with similar signatures which do not follow the standard "throws GError" pattern.
Created attachment 205717 [details] [review] Support functions which return GError GStreamer has the following method: void gst_message_parse_error ( GstMessage *message, GError **error, gchar **debug_message); With this patch, we marshal the GError out parameter as a GObject.GError exception, but return it rather than throwing it. The test cases cover two variations on the theme of the function above (one with (transfer full), as in GStreamer, and another with (transfer none)) as well as a function with return type GError *.
These patches implement the direction Christian cares about. I assume that exposing GErrors as (unthrown) instances of GObject.GError is okay. The other direction is a work-in-progress. (While starting on it, I noticed that the error paths of http://git.gnome.org/browse/pygobject/tree/gi/_glib/pyglib.c#n343 leak if PYGLIB_PyUnicode_Check/PYGLIB_PyLong_Check fail.)
Created attachment 205880 [details] [review] Don't leak when marshalling GErrors to C Python-land GLib.GErrors are supposed to have three attributes: "message", "domain" and "code". If those attributes are missing, or they have the wrong types, the C GError is filled in with a message describing the error. The present-but-ill-typed code paths did not DECREF the ill-typed values.
Comment on attachment 205716 [details] [review] tests: add test functions which return GErrors Attachment 205716 [details] pushed as 1ab4040 - tests: add test functions which return GErrors
Pushed, thanks! Attachment 205717 [details] pushed as adcfe96 - Support functions which return GError Attachment 205880 [details] pushed as 4b9dc03 - Don't leak when marshalling GErrors to C