From 6524d274625d920d5711b7f2d324904af787188a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Feb 2011 06:04:05 +0000 Subject: py api was raising SystemError exception incorrectly, this is intended for internal interpreter problems. Replace most with RuntimeError. --- source/blender/python/generic/mathutils.c | 8 ++++---- source/blender/python/generic/py_capi_utils.c | 4 ++-- source/blender/python/intern/bpy_interface.c | 2 +- source/blender/python/intern/bpy_operator.c | 16 ++++++++-------- source/blender/python/intern/bpy_props.c | 2 +- source/blender/python/intern/bpy_rna.c | 16 ++++++++-------- source/blender/python/intern/bpy_util.c | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) (limited to 'source/blender/python') diff --git a/source/blender/python/generic/mathutils.c b/source/blender/python/generic/mathutils.c index 0098335169b..1f802edcdea 100644 --- a/source/blender/python/generic/mathutils.c +++ b/source/blender/python/generic/mathutils.c @@ -273,7 +273,7 @@ int _BaseMathObject_ReadCallback(BaseMathObject *self) return 1; if(!PyErr_Occurred()) - PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name); return 0; } @@ -284,7 +284,7 @@ int _BaseMathObject_WriteCallback(BaseMathObject *self) return 1; if(!PyErr_Occurred()) - PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name); return 0; } @@ -295,7 +295,7 @@ int _BaseMathObject_ReadIndexCallback(BaseMathObject *self, int index) return 1; if(!PyErr_Occurred()) - PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name); return 0; } @@ -306,7 +306,7 @@ int _BaseMathObject_WriteIndexCallback(BaseMathObject *self, int index) return 1; if(!PyErr_Occurred()) - PyErr_Format(PyExc_SystemError, "%s user has become invalid", Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, "%s user has become invalid", Py_TYPE(self)->tp_name); return 0; } diff --git a/source/blender/python/generic/py_capi_utils.c b/source/blender/python/generic/py_capi_utils.c index dedd6c1bcf4..e8618883874 100644 --- a/source/blender/python/generic/py_capi_utils.c +++ b/source/blender/python/generic/py_capi_utils.c @@ -78,7 +78,7 @@ void PyC_FileAndNum(const char **filename, int *lineno) if (filename) { co_filename= PyC_Object_GetAttrStringArgs(frame, 2, "f_code", "co_filename"); if (co_filename==NULL) { - PyErr_SetString(PyExc_SystemError, "Could not access sys._getframe().f_code.co_filename"); + PyErr_SetString(PyExc_RuntimeError, "Could not access sys._getframe().f_code.co_filename"); Py_DECREF(frame); return; } @@ -109,7 +109,7 @@ void PyC_FileAndNum(const char **filename, int *lineno) if (lineno) { f_lineno= PyObject_GetAttrString(frame, "f_lineno"); if (f_lineno==NULL) { - PyErr_SetString(PyExc_SystemError, "Could not access sys._getframe().f_lineno"); + PyErr_SetString(PyExc_RuntimeError, "Could not access sys._getframe().f_lineno"); Py_DECREF(frame); return; } diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 0e9532aa726..d07e50398d9 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -400,7 +400,7 @@ static int python_script_exec(bContext *C, const char *fn, struct Text *text, st #endif } else { - PyErr_Format(PyExc_SystemError, "Python file \"%s\" could not be opened: %s", fn, strerror(errno)); + PyErr_Format(PyExc_IOError, "Python file \"%s\" could not be opened: %s", fn, strerror(errno)); py_result= NULL; } } diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c index bdf4027e509..a70ea2e9b4a 100644 --- a/source/blender/python/intern/bpy_operator.c +++ b/source/blender/python/intern/bpy_operator.c @@ -60,7 +60,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) bContext *C= (bContext *)BPy_GetContext(); if(C==NULL) { - PyErr_SetString(PyExc_SystemError, "Context is None, cant poll any operators"); + PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators"); return NULL; } @@ -70,7 +70,7 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_SystemError, "Polling operator \"bpy.ops.%s\" error, could not be found", opname); + PyErr_Format(PyExc_AttributeError, "Polling operator \"bpy.ops.%s\" error, could not be found", opname); return NULL; } @@ -127,7 +127,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) bContext *C = (bContext *)BPy_GetContext(); if(C==NULL) { - PyErr_SetString(PyExc_SystemError, "Context is None, cant poll any operators"); + PyErr_SetString(PyExc_RuntimeError, "Context is None, cant poll any operators"); return NULL; } @@ -137,12 +137,12 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_SystemError, "Calling operator \"bpy.ops.%s\" error, could not be found", opname); + PyErr_Format(PyExc_LookupError, "Calling operator \"bpy.ops.%s\" error, could not be found", opname); return NULL; } if(!pyrna_write_check()) { - PyErr_Format(PyExc_SystemError, "Calling operator \"bpy.ops.%s\" error, can't modify blend data in this state (drawing/rendering)", opname); + PyErr_Format(PyExc_RuntimeError, "Calling operator \"bpy.ops.%s\" error, can't modify blend data in this state (drawing/rendering)", opname); return NULL; } @@ -170,7 +170,7 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args) if(WM_operator_poll_context((bContext*)C, ot, context) == FALSE) { const char *msg= CTX_wm_operator_poll_msg_get(C); - PyErr_Format(PyExc_SystemError, "Operator bpy.ops.%.200s.poll() %.200s", opname, msg ? msg : "failed, context is incorrect"); + PyErr_Format(PyExc_RuntimeError, "Operator bpy.ops.%.200s.poll() %.200s", opname, msg ? msg : "failed, context is incorrect"); CTX_wm_operator_poll_msg_set(C, NULL); /* better set to NULL else it could be used again */ error_val= -1; } @@ -261,7 +261,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) bContext *C= (bContext *)BPy_GetContext(); if(C==NULL) { - PyErr_SetString(PyExc_SystemError, "Context is None, cant get the string representation of this object."); + PyErr_SetString(PyExc_RuntimeError, "Context is None, cant get the string representation of this object."); return NULL; } @@ -271,7 +271,7 @@ static PyObject *pyop_as_string(PyObject *UNUSED(self), PyObject *args) ot= WM_operatortype_find(opname, TRUE); if (ot == NULL) { - PyErr_Format(PyExc_SystemError, "_bpy.ops.as_string: operator \"%.200s\"could not be found", opname); + PyErr_Format(PyExc_AttributeError, "_bpy.ops.as_string: operator \"%.200s\"could not be found", opname); return NULL; } diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index 972ba57d5e1..2bdaa5267e1 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -752,7 +752,7 @@ static StructRNA *pointer_type_from_py(PyObject *value, const char *error_prefix } if(!RNA_struct_is_a(srna, &RNA_PropertyGroup)) { - PyErr_Format(PyExc_SystemError, "%.200s expected an RNA type derived from PropertyGroup", error_prefix); + PyErr_Format(PyExc_TypeError, "%.200s expected an RNA type derived from PropertyGroup", error_prefix); return NULL; } diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index c0baf089094..fa01eefa867 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -567,7 +567,7 @@ static PyObject *pyrna_prop_str( BPy_PropertyRNA *self ) int type= RNA_property_type(self->prop); if(RNA_enum_id_from_value(property_type_items, type, &type_id)==0) { - PyErr_SetString(PyExc_SystemError, "could not use property type, internal error"); /* should never happen */ + PyErr_SetString(PyExc_RuntimeError, "could not use property type, internal error"); /* should never happen */ return NULL; } else { @@ -3538,11 +3538,11 @@ static PyObject *foreach_getset(BPy_PropertyRNA *self, PyObject *args, int set) if(PyErr_Occurred()) { /* Maybe we could make our own error */ PyErr_Print(); - PyErr_SetString(PyExc_SystemError, "could not access the py sequence"); + PyErr_SetString(PyExc_TypeError, "could not access the py sequence"); return NULL; } if (!ok) { - PyErr_SetString(PyExc_SystemError, "internal error setting the array"); + PyErr_SetString(PyExc_RuntimeError, "internal error setting the array"); return NULL; } @@ -4967,7 +4967,7 @@ static PyObject *pyrna_basetype_getattro( BPy_BaseTypeRNA *self, PyObject *pynam else if (RNA_property_collection_lookup_string(&self->ptr, self->prop, name, &newptr)) { ret= pyrna_struct_Subtype(&newptr); if (ret==NULL) { - PyErr_Format(PyExc_SystemError, "bpy.types.%.200s subtype could not be generated, this is a bug!", _PyUnicode_AsString(pyname)); + PyErr_Format(PyExc_RuntimeError, "bpy.types.%.200s subtype could not be generated, this is a bug!", _PyUnicode_AsString(pyname)); } } else { @@ -5056,18 +5056,18 @@ StructRNA *pyrna_struct_as_srna(PyObject *self, int parent, const char *error_pr } if(py_srna==NULL) { - PyErr_Format(PyExc_SystemError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_RuntimeError, "%.200s, missing bl_rna attribute from '%.200s' instance (may not be registered)", error_prefix, Py_TYPE(self)->tp_name); return NULL; } if(!BPy_StructRNA_Check(py_srna)) { - PyErr_Format(PyExc_SystemError, "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", error_prefix, Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute wrong type '%.200s' on '%.200s'' instance", error_prefix, Py_TYPE(py_srna)->tp_name, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } if(py_srna->ptr.type != &RNA_Struct) { - PyErr_Format(PyExc_SystemError, "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", error_prefix, Py_TYPE(self)->tp_name); + PyErr_Format(PyExc_TypeError, "%.200s, bl_rna attribute not a RNA_Struct, on '%.200s'' instance", error_prefix, Py_TYPE(self)->tp_name); Py_DECREF(py_srna); return NULL; } @@ -5895,7 +5895,7 @@ static PyObject *pyrna_unregister_class(PyObject *UNUSED(self), PyObject *py_cla RNA_PROP_END; if(prop_identifier) { - PyErr_Format(PyExc_SystemError, "unregister_class(...): Cant unregister %s because %s.%s pointer property is using this", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); + PyErr_Format(PyExc_RuntimeError, "unregister_class(...): can't unregister %s because %s.%s pointer property is using this", RNA_struct_identifier(srna), RNA_struct_identifier(srna_iter), prop_identifier); return NULL; } } diff --git a/source/blender/python/intern/bpy_util.c b/source/blender/python/intern/bpy_util.c index 0e030170a25..63a397769c3 100644 --- a/source/blender/python/intern/bpy_util.c +++ b/source/blender/python/intern/bpy_util.c @@ -151,7 +151,7 @@ short BPy_reports_to_error(ReportList *reports, const short clear) } if(report_str) { - PyErr_SetString(PyExc_SystemError, report_str); + PyErr_SetString(PyExc_RuntimeError, report_str); MEM_freeN(report_str); } -- cgit v1.2.3