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 666098 - gerrors need to be marshalled (needed by GStreamer bindings)
gerrors need to be marshalled (needed by GStreamer bindings)
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-12-13 16:17 UTC by Christian Fredrik Kalager Schaller
Modified: 2012-01-24 14:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
tests: add test functions which return GErrors (4.01 KB, patch)
2012-01-20 18:19 UTC, Will Thompson
committed Details | Review
Support functions which return GError (6.67 KB, patch)
2012-01-20 18:19 UTC, Will Thompson
committed Details | Review
Don't leak when marshalling GErrors to C (1.67 KB, patch)
2012-01-23 13:59 UTC, Will Thompson
committed Details | Review

Description Christian Fredrik Kalager Schaller 2011-12-13 16:17:42 UTC


  • File "/home/cschalle/devel/transmageddon/src/transcoder_engine.py", line 316 in on_message
    err, debug = message.parse_error()
  • File "/usr/lib/python2.7/site-packages/gi/types.py", line 43 in function
    return info.invoke(*args, **kwargs)
NotImplementedError: Marshalling for gerror to PyObject is not implemented

Comment 1 Christian Fredrik Kalager Schaller 2011-12-13 16:25:48 UTC
Re-assigning to python introspection as not a GStreamer issue
Comment 2 Christian Fredrik Kalager Schaller 2011-12-13 16:28:19 UTC
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
Comment 3 Christian Fredrik Kalager Schaller 2011-12-13 16:42:37 UTC
Moving to glib/introspection after suggestion in #pygtk
Comment 4 johnp 2011-12-13 16:54:17 UTC
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.
Comment 5 johnp 2011-12-13 16:55:43 UTC
Should be in pygi_marshal_to_py.c but in that case we also want to cover pygi_marshal_from_py.
Comment 6 johnp 2011-12-13 17:55:03 UTC
moving to pygobject
Comment 7 Will Thompson 2012-01-20 18:19:05 UTC
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.
Comment 8 Will Thompson 2012-01-20 18:19:27 UTC
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 *.
Comment 9 Will Thompson 2012-01-20 18:22:32 UTC
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.)
Comment 10 Will Thompson 2012-01-23 13:59:06 UTC
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 11 Tomeu Vizoso 2012-01-24 14:51:42 UTC
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
Comment 12 Tomeu Vizoso 2012-01-24 14:53:39 UTC
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