[pygobject] Give more informative error when setting property to incorrect type



commit 10214ba2d96fd6d66eeea159219f585abff8632a
Author: Simon Feltman <sfeltman src gnome org>
Date:   Thu Mar 7 15:34:49 2013 -0800

    Give more informative error when setting property to incorrect type
    
    https://bugzilla.gnome.org/show_bug.cgi?id=695420

 gi/_gobject/pygobject.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/gi/_gobject/pygobject.c b/gi/_gobject/pygobject.c
index 8673e79..93b42ee 100644
--- a/gi/_gobject/pygobject.c
+++ b/gi/_gobject/pygobject.c
@@ -341,8 +341,14 @@ set_property_from_pspec(GObject *obj,
 
     g_value_init(&value, G_PARAM_SPEC_VALUE_TYPE(pspec));
     if (pyg_param_gvalue_from_pyobject(&value, pvalue, pspec) < 0) {
-       PyErr_SetString(PyExc_TypeError,
-                       "could not convert argument to correct param type");
+        PyObject *pvalue_str = PyObject_Str(pvalue);
+       PyErr_Format(PyExc_TypeError,
+                    "could not convert '%s' to type '%s' when setting property '%s.%s'",
+                    PYGLIB_PyUnicode_AsString(pvalue_str),
+                    g_type_name(G_PARAM_SPEC_VALUE_TYPE(pspec)),
+                    G_OBJECT_TYPE_NAME(obj),
+                    pspec->name);
+       Py_DECREF(pvalue_str);
        return FALSE;
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]