Commit 07df124d authored by Steve Frécinaux's avatar Steve Frécinaux

Make the "wrong argument count" exception more explicit.

Previously we had messages like this one:
TypeError: takes exactly 2 argument(s) (1 given)

With this patch, they become like this:
TypeError: get_end_iter() takes exactly 2 argument(s) (1 given)

It makes things much easier to debug when there are several pygi calls
on the same line.
parent b435319f
......@@ -233,7 +233,8 @@ _prepare_invocation_state (struct invocation_state *state,
if (state->n_py_args != n_py_args_expected) {
PyErr_Format (PyExc_TypeError,
"takes exactly %zd argument(s) (%zd given)",
"%s() takes exactly %zd argument(s) (%zd given)",
g_base_info_get_name ( (GIBaseInfo *) function_info),
n_py_args_expected, state->n_py_args);
return FALSE;
......@@ -79,6 +79,12 @@ class TestEverything(unittest.TestCase):
self.assertEquals(struct_b.nested_a.some_double, struct_b_clone.nested_a.some_double)
self.assertEquals(struct_b.nested_a.some_enum, struct_b_clone.nested_a.some_enum)
def test_wrong_type_of_arguments(self):
except TypeError, e:
self.assertEquals(e.args, ("test_int8() takes exactly 1 argument(s) (0 given)",))
class TestNullableArgs(unittest.TestCase):
def test_in_nullable_hash(self):
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment