GNOME Bugzilla – Bug 642715
Can't have a GError out parameter to a Python callback without throwing exception.
Last modified: 2011-02-19 08:51:42 UTC
Right now we can't marshal GErrors, so a NotImplementedException is thrown. This is a problem for callbacks such as GdkPixbufSaveFunc, which has a GError as an out parameter. GdkPixbufSaveFunc requires the return value (True/False) as well as the one out parameter to be returned from the Python callback. If you do "return True", an assertion fails because there are not enough out parameters for the closure marshaller. However if you do "return (True, None)" a NotImplementedException is thrown because we don't support marshalling GErrors. It should be that if Py_None is passed, the GError is set to NULL. Any other Python value should still throw NotImplementedException until we can marshal them properly.
Created attachment 181280 [details] [review] [GI] Marshal Py_None to NULL for GError**.
In order to keep ABI consistent I propose we always return NULL for callbacks that return GErrors. The user should never be returning GErrors but should instead raise python or glib errors. Since we can not marshal a python error to a GError yet the proposed solution is to simply return NULL for now in the GI callback return marshallers. This way the ABI for returning from such a function would always be: return boolean instead of return (boolean, None) for now and then return boolean some version later
Comment on attachment 181280 [details] [review] [GI] Marshal Py_None to NULL for GError**. I don't think we should ever support manipulating GErrors. This should be fixed by treating GError returns as special and returning NULL always for right now. They should not be treated as out values.
Created attachment 181281 [details] [review] [GI] Skip GError out parameters in Python closure. Python code should have never have to explicitely return a GError. Once we are able to marshal exceptions the Python code should throw an exception instead. Until then, set GError to NULL, and don't complain if a Python function doesn't return an arg for it.
Comment on attachment 181281 [details] [review] [GI] Skip GError out parameters in Python closure. looks good, commit to both branches