From fad4c5b309c9c625f1c42e12df9377fbb00ef12f Mon Sep 17 00:00:00 2001 From: Frederic Peters Date: Tue, 29 Apr 2008 12:03:48 +0000 Subject: [project @ fpeters@0d.be-20071031161008-c5jqe7topkxoaoe0] raise TypeError when assigning a Python list to a member expecting a tuple Original author: Frederic Peters Date: 2007-10-31 17:10:08.047000+01:00 --- bindings/lang_python.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bindings/lang_python.py b/bindings/lang_python.py index 16ee7996..de31fd09 100644 --- a/bindings/lang_python.py +++ b/bindings/lang_python.py @@ -459,8 +459,12 @@ register_constants(PyObject *d) print >> fd, ' this->%s = g_strdup(value);' % m[1] elif parse_format == 'O' and arg_type == 'GList*': elem_type = m[2].get('elem_type') - # XXX: raise appropriate exception (TypeError) - print >> fd, ' if (!PyTuple_Check(cvt_value)) return NULL;' + print >> fd, '''\ + if (!PyTuple_Check(cvt_value)) { + PyErr_SetString(PyExc_TypeError, "value should be tuple"); + return NULL; + } +''' if elem_type == 'char*': print >> fd, '''\ if (this->%(v)s) { -- cgit