From c20db2d70de4b730d0dd3e62333587d13e6d20a1 Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Wed, 4 Apr 2018 11:24:57 +0200 Subject: pygi_gint_from_py: fix wrong range in error message, add test --- gi/pygi-basictype.c | 2 +- tests/test_gi.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gi/pygi-basictype.c b/gi/pygi-basictype.c index 089a7dde..d9e4b821 100644 --- a/gi/pygi-basictype.c +++ b/gi/pygi-basictype.c @@ -503,7 +503,7 @@ pygi_gint_from_py (PyObject *object, gint *result) if (long_value < G_MININT || long_value > G_MAXINT) { PyErr_Format (PyExc_OverflowError, "%ld not in range %d to %d", - long_value, (int)G_MININT8, (int)G_MAXINT8); + long_value, (int)G_MININT, (int)G_MAXINT); return FALSE; } diff --git a/tests/test_gi.py b/tests/test_gi.py index db138e66..bf51874c 100644 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -1610,6 +1610,11 @@ class TestGValue(unittest.TestCase): self.assertRaises(OverflowError, GIMarshallingTests.gvalue_flat_array, [GLib.MININT - 1, "42", True]) + with pytest.raises(OverflowError, + match=r'.*not in range %d to %d.*' % ( + GLib.MININT, GLib.MAXINT)): + GIMarshallingTests.gvalue_flat_array([GLib.MAXINT + 1, "42", True]) + def test_gvalue_flat_array_out(self): values = GIMarshallingTests.return_gvalue_flat_array() self.assertEqual(values, [42, '42', True]) -- cgit v1.2.1