Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-12 18:18:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-12 18:18:08 +0300
commit90d42e114c2b8828e84a5e229da0de0a23ec0a83 (patch)
tree0c80b5f1214cfba5422f0b587b116e66c7a5c0af /source
parenta5e59ede6e275d89fb74ab2e2ae1ee581e08356b (diff)
py/rna: BPy_reports_to_error() now takes the exception type as an argument and returns -1 as an error value
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/intern/bpy_operator.c3
-rw-r--r--source/blender/python/intern/bpy_rna.c6
-rw-r--r--source/blender/python/intern/bpy_rna_anim.c8
-rw-r--r--source/blender/python/intern/bpy_util.c6
-rw-r--r--source/blender/python/intern/bpy_util.h2
5 files changed, 12 insertions, 13 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index 73a8deb1b97..ad1bce89896 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -198,8 +198,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
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) {
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index f7f451b50ad..aa657f34f39 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -4223,10 +4223,10 @@ static PyObject *pyrna_func_call(PyObject *self, PyObject *args, PyObject *kw)
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 @@ static PyObject *pyrna_register_class(PyObject *UNUSED(self), PyObject *py_class
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.
diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c
index e000f19be82..9dc6fd28762 100644
--- a/source/blender/python/intern/bpy_rna_anim.c
+++ b/source/blender/python/intern/bpy_rna_anim.c
@@ -183,7 +183,7 @@ PyObject *pyrna_struct_keyframe_insert(BPy_StructRNA *self, PyObject *args, PyOb
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 @@ PyObject *pyrna_struct_keyframe_delete(BPy_StructRNA *self, PyObject *args, PyOb
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 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args)
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 @@ PyObject *pyrna_struct_driver_remove(BPy_StructRNA *self, PyObject *args)
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);
diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c
index 3d5090b73fa..ccbee2abcd1 100644
--- a/source/blender/python/intern/bpy_util.c
+++ b/source/blender/python/intern/bpy_util.c
@@ -57,7 +57,7 @@ char *BPy_enum_as_string(EnumPropertyItem *item)
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 @@ short BPy_reports_to_error(ReportList *reports, const short clear)
}
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;
}
diff --git a/source/blender/python/intern/bpy_util.h b/source/blender/python/intern/bpy_util.h
index 7d1947a5a52..b16c8fe2e8c 100644
--- a/source/blender/python/intern/bpy_util.h
+++ b/source/blender/python/intern/bpy_util.h
@@ -44,7 +44,7 @@ char *BPy_enum_as_string(struct EnumPropertyItem *item);
#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! */