summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Feltman <sfeltman@src.gnome.org>2014-05-03 22:56:49 -0700
committerSimon Feltman <sfeltman@src.gnome.org>2014-05-03 23:26:22 -0700
commit9080215e862a73ddcce16476f4dc4492a88dd3f2 (patch)
tree35ed9268a44b2e1aad7d64933371918d10664d28
parentf129e78d579b7897cb86111c524d87b5b12019ad (diff)
downloadpygobject-9080215e862a73ddcce16476f4dc4492a88dd3f2.tar.gz
Add gi.CallableInfo.can_throw_gerror()
Add static binding for g_callable_info_can_throw_gerror.
-rw-r--r--gi/pygi-info.c10
-rw-r--r--tests/test_repository.py16
2 files changed, 26 insertions, 0 deletions
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index 5ce43372..43ee7110 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -754,6 +754,15 @@ _wrap_g_callable_info_get_return_attribute (PyGIBaseInfo *self, PyObject *py_nam
}
}
+static PyObject *
+_wrap_g_callable_info_can_throw_gerror (PyGIBaseInfo *self)
+{
+ if (g_callable_info_can_throw_gerror (self->info))
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
static PyMethodDef _PyGICallableInfo_methods[] = {
{ "invoke", (PyCFunction) _wrap_g_callable_info_invoke, METH_VARARGS | METH_KEYWORDS },
{ "get_arguments", (PyCFunction) _wrap_g_callable_info_get_arguments, METH_NOARGS },
@@ -762,6 +771,7 @@ static PyMethodDef _PyGICallableInfo_methods[] = {
{ "may_return_null", (PyCFunction) _wrap_g_callable_info_may_return_null, METH_NOARGS },
{ "skip_return", (PyCFunction) _wrap_g_callable_info_skip_return, METH_NOARGS },
{ "get_return_attribute", (PyCFunction) _wrap_g_callable_info_get_return_attribute, METH_O },
+ { "can_throw_gerror", (PyCFunction) _wrap_g_callable_info_can_throw_gerror, METH_NOARGS },
{ NULL, NULL, 0 }
};
diff --git a/tests/test_repository.py b/tests/test_repository.py
index 88132e62..6f62214f 100644
--- a/tests/test_repository.py
+++ b/tests/test_repository.py
@@ -309,6 +309,22 @@ class Test(unittest.TestCase):
self.assertEqual(vfunc.get_offset(), 0xFFFF) # unknown offset
self.assertEqual(vfunc.get_signal(), None)
+ def test_callable_can_throw_gerror(self):
+ info = repo.find_by_name('GIMarshallingTests', 'Object')
+ invoker = find_child_info(info, 'get_methods', 'vfunc_meth_with_error')
+ vfunc = find_child_info(info, 'get_vfuncs', 'vfunc_meth_with_err')
+
+ self.assertTrue(invoker.can_throw_gerror())
+ self.assertTrue(vfunc.can_throw_gerror())
+
+ # Test that args do not include the GError**
+ self.assertEqual(len(invoker.get_arguments()), 1)
+ self.assertEqual(len(vfunc.get_arguments()), 1)
+
+ # Sanity check method that does not throw.
+ invoker_no_throws = find_child_info(info, 'get_methods', 'method_int8_in')
+ self.assertFalse(invoker_no_throws.can_throw_gerror())
+
def test_flags_double_registration_error(self):
# a warning is printed for double registration and pygobject will
# also raise a RuntimeError.