summaryrefslogtreecommitdiff
path: root/gi
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@gnome.org>2016-02-19 17:13:57 +0100
committerThibault Saunier <tsaunier@gnome.org>2016-02-20 21:47:09 +0100
commiteb043251ee7af7c419bad25f1b5275c6fa31d40a (patch)
tree967928db32470f3437efeb9eaf13196283e6155b /gi
parent96aaedf8b93b8e9ec21aa6a76a7f94746662e2b8 (diff)
Fix bug when checking template object type
Diffstat (limited to 'gi')
-rw-r--r--gi/overrides/gstmodule.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/gi/overrides/gstmodule.c b/gi/overrides/gstmodule.c
index c40c521..e426165 100644
--- a/gi/overrides/gstmodule.c
+++ b/gi/overrides/gstmodule.c
@@ -147,10 +147,27 @@ add_templates (gpointer gclass, PyObject * templates)
for (i = 0; i < len; i++) {
templ = (PyGObject *) PyTuple_GetItem (templates, i);
- if (!pygobject_check (templates, &PyGObject_Type) ||
- GST_IS_PAD_TEMPLATE (pygobject_get (templates)) == FALSE) {
- PyErr_SetString (PyExc_TypeError,
- "entries for __gsttemplates__ must be of type GstPadTemplate");
+
+ if (!pygobject_check (templ, &PyGObject_Type)) {
+ PyObject *repr = PyObject_Repr ((PyObject *) templ);
+#if PY_VERSION_HEX < 0x03000000
+ PyErr_Format (PyExc_TypeError, "expected GObject but got %s",
+ PyString_AsString (repr));
+#else
+ PyErr_Format (PyExc_TypeError, "expected GObject but got %s",
+ _PyUnicode_AsString (repr));
+#endif
+ Py_DECREF (repr);
+
+ return -1;
+ } else if (!GST_IS_PAD_TEMPLATE (pygobject_get (templ))) {
+ gchar *error =
+ g_strdup_printf
+ ("entries for __gsttemplates__ must be of type GstPadTemplate (%s)",
+ G_OBJECT_TYPE_NAME (pygobject_get (templ)));
+ PyErr_SetString (PyExc_TypeError, error);
+ g_free (error);
+
return -1;
}
}