summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gi/Makefile.am3
-rw-r--r--gi/pygi-invoke.c12
-rw-r--r--tests/test_gi.py10
3 files changed, 15 insertions, 10 deletions
diff --git a/gi/Makefile.am b/gi/Makefile.am
index 8b1639d5..abd895e8 100644
--- a/gi/Makefile.am
+++ b/gi/Makefile.am
@@ -25,7 +25,8 @@ _gi_la_LDFLAGS = \
-export-symbols-regex "init_gi|PyInit__gi"
_gi_la_LIBADD = \
$(GI_LIBS) \
- $(PYTHON_LIBS)
+ $(PYTHON_LIBS) \
+ $(top_builddir)/glib/libpyglib-2.0-@PYTHON_BASENAME@.la
_gi_la_SOURCES = \
pygi-repository.c \
pygi-repository.h \
diff --git a/gi/pygi-invoke.c b/gi/pygi-invoke.c
index a92c68e7..e998df74 100644
--- a/gi/pygi-invoke.c
+++ b/gi/pygi-invoke.c
@@ -21,6 +21,7 @@
* USA
*/
+#include <pyglib.h>
#include "pygi-invoke.h"
struct invocation_state
@@ -604,10 +605,7 @@ _invoke_function (struct invocation_state *state,
pyg_end_allow_threads;
if (!retval) {
- g_assert (error != NULL);
- /* TODO: raise the right error, out of the error domain. */
- PyErr_SetString (PyExc_RuntimeError, error->message);
- g_error_free (error);
+ pyglib_error_check(&error);
/* TODO: release input arguments. */
@@ -619,11 +617,7 @@ _invoke_function (struct invocation_state *state,
error = state->args[state->error_arg_pos]->v_pointer;
- if (*error != NULL) {
- /* TODO: raise the right error, out of the error domain, if applicable. */
- PyErr_SetString (PyExc_Exception, (*error)->message);
- g_error_free (*error);
-
+ if (pyglib_error_check(error)) {
/* TODO: release input arguments. */
return FALSE;
diff --git a/tests/test_gi.py b/tests/test_gi.py
index 531da51d..3a61b319 100644
--- a/tests/test_gi.py
+++ b/tests/test_gi.py
@@ -1442,6 +1442,16 @@ class TestMultiOutputArgs(unittest.TestCase):
def test_int_return_out(self):
self.assertEquals((6, 7), GIMarshallingTests.int_return_out())
+class TestGErrorException(unittest.TestCase):
+ def test_gerror_exception(self):
+ self.assertRaises(GObject.GError, GIMarshallingTests.gerror)
+ try:
+ GIMarshallingTests.gerror()
+ except Exception, error:
+ self.assertEquals(error.domain, GIMarshallingTests.CONSTANT_GERROR_DOMAIN)
+ self.assertEquals(error.code, GIMarshallingTests.CONSTANT_GERROR_CODE)
+ self.assertEquals(error.message, GIMarshallingTests.CONSTANT_GERROR_MESSAGE)
+
# Interface