[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35496] trunk/blender/source/blender/ python/intern: py/rna: BPy_reports_to_error() now takes the exception type as an argument and returns -1 as an error value
Campbell Barton
ideasman42 at gmail.com
Sat Mar 12 16:18:08 CET 2011
Revision: 35496
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35496
Author: campbellbarton
Date: 2011-03-12 15:18:08 +0000 (Sat, 12 Mar 2011)
Log Message:
-----------
py/rna: BPy_reports_to_error() now takes the exception type as an argument and returns -1 as an error value
Modified Paths:
--------------
trunk/blender/source/blender/python/intern/bpy_operator.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/intern/bpy_rna_anim.c
trunk/blender/source/blender/python/intern/bpy_util.c
trunk/blender/source/blender/python/intern/bpy_util.h
Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator.c 2011-03-12 15:15:40 UTC (rev 35495)
+++ trunk/blender/source/blender/python/intern/bpy_operator.c 2011-03-12 15:18:08 UTC (rev 35496)
@@ -198,8 +198,7 @@
operator_ret= WM_operator_call_py(C, ot, context, &ptr, reports);
- if(BPy_reports_to_error(reports, FALSE))
- error_val = -1;
+ error_val= BPy_reports_to_error(reports, PyExc_RuntimeError, FALSE);
/* operator output is nice to have in the terminal/console too */
if(reports->list.first) {
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2011-03-12 15:15:40 UTC (rev 35495)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2011-03-12 15:18:08 UTC (rev 35496)
@@ -4223,10 +4223,10 @@
BKE_reports_init(&reports, RPT_STORE);
RNA_function_call(C, &reports, self_ptr, self_func, &parms);
- err= (BPy_reports_to_error(&reports, TRUE))? -1: 0;
+ err= (BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE));
/* return value */
- if(err==0) {
+ if(err != -1) {
if (ret_len > 0) {
if (ret_len > 1) {
ret= PyTuple_New(ret_len);
@@ -6127,7 +6127,7 @@
srna_new= reg(C, &reports, py_class, identifier, bpy_class_validate, bpy_class_call, bpy_class_free);
- if(BPy_reports_to_error(&reports, TRUE))
+ if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
/* python errors validating are not converted into reports so the check above will fail.
Modified: trunk/blender/source/blender/python/intern/bpy_rna_anim.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna_anim.c 2011-03-12 15:15:40 UTC (rev 35495)
+++ trunk/blender/source/blender/python/intern/bpy_rna_anim.c 2011-03-12 15:18:08 UTC (rev 35496)
@@ -183,7 +183,7 @@
result= insert_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN((void *)path_full);
- if(BPy_reports_to_error(&reports, TRUE))
+ if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
return PyBool_FromLong(result);
@@ -228,7 +228,7 @@
result= delete_keyframe(&reports, (ID *)self->ptr.id.data, NULL, group_name, path_full, index, cfra, 0);
MEM_freeN((void *)path_full);
- if(BPy_reports_to_error(&reports, TRUE))
+ if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
return PyBool_FromLong(result);
@@ -270,7 +270,7 @@
result= ANIM_add_driver(&reports, (ID *)self->ptr.id.data, path_full, index, 0, DRIVER_TYPE_PYTHON);
- if(BPy_reports_to_error(&reports, TRUE))
+ if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
if(result) {
@@ -345,7 +345,7 @@
MEM_freeN((void *)path_full);
- if(BPy_reports_to_error(&reports, TRUE))
+ if(BPy_reports_to_error(&reports, PyExc_RuntimeError, TRUE) == -1)
return NULL;
return PyBool_FromLong(result);
Modified: trunk/blender/source/blender/python/intern/bpy_util.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_util.c 2011-03-12 15:15:40 UTC (rev 35495)
+++ trunk/blender/source/blender/python/intern/bpy_util.c 2011-03-12 15:18:08 UTC (rev 35496)
@@ -57,7 +57,7 @@
return cstring;
}
-short BPy_reports_to_error(ReportList *reports, const short clear)
+short BPy_reports_to_error(ReportList *reports, PyObject *exception, const short clear)
{
char *report_str;
@@ -68,11 +68,11 @@
}
if(report_str) {
- PyErr_SetString(PyExc_RuntimeError, report_str);
+ PyErr_SetString(exception, report_str);
MEM_freeN(report_str);
}
- return (report_str != NULL);
+ return (report_str != NULL) ? 0 : -1;
}
Modified: trunk/blender/source/blender/python/intern/bpy_util.h
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_util.h 2011-03-12 15:15:40 UTC (rev 35495)
+++ trunk/blender/source/blender/python/intern/bpy_util.h 2011-03-12 15:18:08 UTC (rev 35496)
@@ -44,7 +44,7 @@
#define BLANK_PYTHON_TYPE {PyVarObject_HEAD_INIT(NULL, 0) NULL}
/* error reporting */
-short BPy_reports_to_error(struct ReportList *reports, const short clear);
+short BPy_reports_to_error(struct ReportList *reports, PyObject *exception, const short clear);
short BPy_errors_to_report(struct ReportList *reports);
/* TODO - find a better solution! */
More information about the Bf-blender-cvs
mailing list