[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27543] trunk/blender/source/blender/ python/intern: made argument conversion for much more verbose, wasnt giving enough info with bad operator args.
Brecht Van Lommel
brecht at blender.org
Tue Mar 16 18:19:43 CET 2010
Revision: 27543
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27543
Author: blendix
Date: 2010-03-16 18:19:42 +0100 (Tue, 16 Mar 2010)
Log Message:
-----------
made argument conversion for much more verbose, wasnt giving enough info with bad operator args.
(commit 27432 by Campbell from render25 branch)
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/intern/bpy_util.c
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2010-03-16 17:15:21 UTC (rev 27542)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2010-03-16 17:19:42 UTC (rev 27543)
@@ -768,7 +768,7 @@
} else /* continue... */
#endif
if (!PySequence_Check(value)) {
- PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment expected a sequence instead of %.200s instance.", error_prefix, Py_TYPE(value)->tp_name);
+ PyErr_Format(PyExc_TypeError, "%.200s RNA array assignment to %.200s.%.200s expected a sequence instead of %.200s instance.", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
/* done getting the length */
@@ -796,7 +796,7 @@
param = PyLong_AsSsize_t( value );
if( param < 0 || param > 1) {
- PyErr_Format(PyExc_TypeError, "%.200s expected True/False or 0/1", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected True/False or 0/1", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
} else {
if(data) *((int*)data)= param;
@@ -808,7 +808,7 @@
{
int param = PyLong_AsSsize_t(value);
if (param==-1 && PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "%.200s expected an int type", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected an int type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
} else {
RNA_property_int_clamp(ptr, prop, ¶m);
@@ -821,7 +821,7 @@
{
float param = PyFloat_AsDouble(value);
if (PyErr_Occurred()) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a float type", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a float type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
} else {
RNA_property_float_clamp(ptr, prop, (float *)¶m);
@@ -835,7 +835,7 @@
char *param = _PyUnicode_AsString(value);
if (param==NULL) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a string type", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
} else {
if(data) *((char**)data)= param;
@@ -864,7 +864,7 @@
}
else {
char *enum_str= pyrna_enum_as_string(ptr, prop);
- PyErr_Format(PyExc_TypeError, "%.200s expected a string enum or a set of strings in (%.200s)", error_prefix, enum_str);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a string enum or a set of strings in (%.2000s)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), enum_str);
MEM_freeN(enum_str);
return -1;
}
@@ -886,13 +886,13 @@
}
if(!BPy_StructRNA_Check(value) && value != Py_None) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptype));
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
return -1;
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
- PyErr_Format(PyExc_TypeError, "%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptype));
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s does not support a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(ptype));
return -1;
} else if(value != Py_None && ((flag & PROP_ID_SELF_CHECK) && ptr->id.data == ((BPy_StructRNA*)value)->ptr.id.data)) {
- PyErr_Format(PyExc_TypeError, "%.200s ID type does not support assignment to its self", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s ID type does not support assignment to its self", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
} else {
BPy_StructRNA *param= (BPy_StructRNA*)value;
@@ -928,7 +928,7 @@
else {
PointerRNA tmp;
RNA_pointer_create(NULL, ptype, NULL, &tmp);
- PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(tmp.type));
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
return -1;
}
}
@@ -936,7 +936,7 @@
if(raise_error) {
PointerRNA tmp;
RNA_pointer_create(NULL, ptype, NULL, &tmp);
- PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(tmp.type));
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), RNA_struct_identifier(tmp.type));
return -1;
}
}
@@ -954,19 +954,26 @@
/* convert a sequence of dict's into a collection */
if(!PySequence_Check(value)) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a sequence of dicts for an RNA collection", error_prefix);
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a sequence for an RNA collection, found a '%.200s' instead", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(value)->tp_name);
return -1;
}
-
+
seq_len = PySequence_Length(value);
for(i=0; i<seq_len; i++) {
item= PySequence_GetItem(value, i);
- if(item==NULL || PyDict_Check(item)==0) {
- PyErr_Format(PyExc_TypeError, "%.200s expected a sequence of dicts for an RNA collection", error_prefix);
+
+ if(item==NULL) {
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s failed to get sequence index '%d' for an RNA collection", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), i);
Py_XDECREF(item);
return -1;
}
+ if(PyDict_Check(item)==0) {
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s expected a each sequence member to be a dict for an RNA collection, found a '%.200s' instead", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), Py_TYPE(item)->tp_name);
+ Py_XDECREF(item);
+ return -1;
+ }
+
if(lb) {
link= MEM_callocN(sizeof(CollectionPointerLink), "PyCollectionPointerLink");
link->ptr= itemptr;
@@ -976,7 +983,13 @@
RNA_property_collection_add(ptr, prop, &itemptr);
if(pyrna_pydict_to_props(&itemptr, item, 1, "Converting a python list to an RNA collection")==-1) {
+ PyObject *msg= BPY_exception_buffer();
+ char *msg_char= _PyUnicode_AsString(msg);
+
+ PyErr_Format(PyExc_TypeError, "%.200s %.200s.%.200s error converting a member of a collection from a dicts into an RNA collection, failed with: %s", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop), msg_char);
+
Py_DECREF(item);
+ Py_DECREF(msg);
return -1;
}
Py_DECREF(item);
@@ -985,7 +998,7 @@
break;
}
default:
- PyErr_Format(PyExc_AttributeError, "%.200s unknown property type (pyrna_py_to_prop)", error_prefix);
+ PyErr_Format(PyExc_AttributeError, "%.200s %.200s.%.200s unknown property type (pyrna_py_to_prop)", error_prefix, RNA_struct_identifier(ptr->type), RNA_property_identifier(prop));
return -1;
break;
}
Modified: trunk/blender/source/blender/python/intern/bpy_util.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_util.c 2010-03-16 17:15:21 UTC (rev 27542)
+++ trunk/blender/source/blender/python/intern/bpy_util.c 2010-03-16 17:19:42 UTC (rev 27543)
@@ -243,8 +243,8 @@
PyErr_Clear();
- /* import StringIO / io
- * string_io = StringIO.StringIO()
+ /* import io
+ * string_io = io.StringIO()
*/
if(! (string_io_mod= PyImport_ImportModule("io")) ) {
More information about the Bf-blender-cvs
mailing list