From 8e21620d279e501fcdcacf6ef6dec6cc7397db0e Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Mon, 11 Aug 2008 20:29:27 +0000 Subject: Bug 540376 – No TypeError raised when type is None MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-08-11 Paul Pogonyshev Bug 540376 – No TypeError raised when type is None * gobject/gobjectmodule.c (pyg_signal_new): Add check on second argument type. * tests/test_signal.py (TestSignalCreation): New test case. svn path=/trunk/; revision=942 --- ChangeLog | 9 +++++++++ gobject/gobjectmodule.c | 8 ++++++++ tests/test_signal.py | 10 ++++++++++ 3 files changed, 27 insertions(+) diff --git a/ChangeLog b/ChangeLog index f3d139e..92292f7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-08-11 Paul Pogonyshev + + Bug 540376 – No TypeError raised when type is None + + * gobject/gobjectmodule.c (pyg_signal_new): Add check on second + argument type. + + * tests/test_signal.py (TestSignalCreation): New test case. + 2008-08-11 Paul Pogonyshev Bug 547104 – improve type wrapper creation diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index b7fadfd..29ccdf2 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1314,12 +1314,20 @@ pyg_signal_new(PyObject *self, PyObject *args) &py_type, &signal_flags, &py_return_type, &py_param_types)) return NULL; + instance_type = pyg_type_from_object(py_type); if (!instance_type) return NULL; + if (!(G_TYPE_IS_INSTANTIATABLE(instance_type) || G_TYPE_IS_INTERFACE(instance_type))) { + PyErr_SetString(PyExc_TypeError, + "argument 2 must be an object type or interface type"); + return NULL; + } + return_type = pyg_type_from_object(py_return_type); if (!return_type) return NULL; + if (!PySequence_Check(py_param_types)) { PyErr_SetString(PyExc_TypeError, "argument 5 must be a sequence of GType codes"); diff --git a/tests/test_signal.py b/tests/test_signal.py index 6c41ece..96e0731 100644 --- a/tests/test_signal.py +++ b/tests/test_signal.py @@ -17,6 +17,16 @@ class D(C): self.arg2 = arg2 C.do_my_signal(self, arg2) +class TestSignalCreation(unittest.TestCase): + # Bug 540376. + def test_illegals(self): + self.assertRaises(TypeError, lambda: gobject.signal_new('test', + None, + 0, + gobject.TYPE_NONE, + (gobject.TYPE_LONG,))) + + class TestChaining(unittest.TestCase): def setUp(self): self.inst = C() -- cgit