diff options
Diffstat (limited to 'source/blender/python/intern/bpy_rna.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 759630b73ac..dff96f74d62 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -8040,14 +8040,21 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item PyObject *py_kw = ((BPy_PropDeferred *)item)->kw; PyObject *py_srna_cobject, *py_ret; + /* Show the function name in errors to help give context. */ + BLI_assert(PyCFunction_CheckExact(py_func)); + PyMethodDef *py_func_method_def = ((PyCFunctionObject *)py_func)->m_ml; + const char *func_name = py_func_method_def->ml_name; + PyObject *args_fake; + const char *key_str = PyUnicode_AsUTF8(key); - if (*PyUnicode_AsUTF8(key) == '_') { + if (*key_str == '_') { PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: " - "%.200s could not register because the property starts with an '_'\n", + "'%.200s' %.200s could not register because it starts with an '_'", RNA_struct_identifier(srna), - PyUnicode_AsUTF8(key)); + key_str, + func_name); return -1; } py_srna_cobject = PyCapsule_New(srna, NULL, NULL); @@ -8066,8 +8073,12 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item *(PyCFunctionWithKeywords)PyCFunction_GET_FUNCTION(py_func) == BPy_CollectionProperty) && RNA_struct_idprops_contains_datablock(type_srna)) { PyErr_Format(PyExc_ValueError, - "bpy_struct \"%.200s\" doesn't support datablock properties\n", - RNA_struct_identifier(srna)); + "bpy_struct \"%.200s\" registration error: " + "'%.200s' %.200s could not register because " + "this type doesn't support data-block properties", + RNA_struct_identifier(srna), + key_str, + func_name); return -1; } } @@ -8085,12 +8096,12 @@ static int deferred_register_prop(StructRNA *srna, PyObject *key, PyObject *item Py_DECREF(args_fake); /* Free's py_srna_cobject too. */ - // PyC_LineSpit(); PyErr_Format(PyExc_ValueError, "bpy_struct \"%.200s\" registration error: " - "%.200s could not register\n", + "'%.200s' %.200s could not register (see previous error)", RNA_struct_identifier(srna), - PyUnicode_AsUTF8(key)); + key_str, + func_name); return -1; } |