py api was raising SystemError exception incorrectly, this is intended for internal...
authorCampbell Barton <ideasman42@gmail.com>
Fri, 18 Feb 2011 06:04:05 +0000 (06:04 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Fri, 18 Feb 2011 06:04:05 +0000 (06:04 +0000)
Replace most with RuntimeError.

source/blender/python/generic/mathutils.c
source/blender/python/generic/py_capi_utils.c
source/blender/python/intern/bpy_interface.c
source/blender/python/intern/bpy_operator.c
source/blender/python/intern/bpy_props.c
source/blender/python/intern/bpy_rna.c
source/blender/python/intern/bpy_util.c
source/gameengine/Expressions/PyObjectPlus.h

index 0098335169b16542685bedf0ddd916f8631bc925..1f802edcdea0a1d9e42df6ae8c3d2f81adb85569 100644 (file)
@@ -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;
 }
 
index dedd6c1bcf48b4bde13f6f3659bce13aa87fec50..e8618883874b504d04ae27fcab443a3f100fb54e 100644 (file)
@@ -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;
                }
index 0e9532aa726b51599a108bc0aa96633815fe4d1e..d07e50398d977787005983bc6c997dbbbd6ab61a 100644 (file)
@@ -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;
                }
        }
index bdf4027e509b901d59e659921bd23bb7544720e8..a70ea2e9b4a0eb5d67fc1f3c0f1c8a774aca379d 100644 (file)
@@ -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;
        }
 
index 972ba57d5e170211687b7b986cb0b0b38734ddf2..2bdaa5267e1ec140153b0ca6a5a0e32169aa828c 100644 (file)
@@ -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;
        }
 
index c0baf0890946110021e05bcbae3e9343e89cbcdf..fa01eefa867d3d0b01b2d2861e73824d3e3ce78e 100644 (file)
@@ -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;
                }               
        }
index 0e030170a25a4ec801364a37dd18e912500d98d5..63a397769c3957bf22dde5ee5b6d3098ea805c15 100644 (file)
@@ -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);
        }
 
index d69be6af5e54e56b107aa58ff03f27162889f8c3..4890a5edb04287823ec62f337c2c3b43a21c19b3 100644 (file)
@@ -169,35 +169,35 @@ typedef struct PyObjectPlus_Proxy {
 #define KX_PYMETHOD(class_name, method_name)                   \
        PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds);         \
        }; \
 
 #define KX_PYMETHOD_VARARGS(class_name, method_name)                   \
        PyObject* Py##method_name(PyObject* args); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args);               \
        }; \
 
 #define KX_PYMETHOD_NOARGS(class_name, method_name)                    \
        PyObject* Py##method_name(); \
        static PyObject* sPy##method_name( PyObject* self) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name();           \
        }; \
        
 #define KX_PYMETHOD_O(class_name, method_name)                 \
        PyObject* Py##method_name(PyObject* value); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value);              \
        }; \
 
 #define KX_PYMETHOD_DOC(class_name, method_name)                       \
        PyObject* Py##method_name(PyObject* args, PyObject* kwds); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args, kwds);         \
        }; \
     static const char method_name##_doc[]; \
@@ -205,7 +205,7 @@ typedef struct PyObjectPlus_Proxy {
 #define KX_PYMETHOD_DOC_VARARGS(class_name, method_name)                       \
        PyObject* Py##method_name(PyObject* args); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(...) - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(args);               \
        }; \
     static const char method_name##_doc[]; \
@@ -213,7 +213,7 @@ typedef struct PyObjectPlus_Proxy {
 #define KX_PYMETHOD_DOC_O(class_name, method_name)                     \
        PyObject* Py##method_name(PyObject* value); \
        static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "(value) - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name(value);              \
        }; \
     static const char method_name##_doc[]; \
@@ -221,7 +221,7 @@ typedef struct PyObjectPlus_Proxy {
 #define KX_PYMETHOD_DOC_NOARGS(class_name, method_name)                        \
        PyObject* Py##method_name(); \
        static PyObject* sPy##method_name( PyObject* self) { \
-               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_SystemError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
+               if(BGE_PROXY_REF(self)==NULL) { PyErr_SetString(PyExc_RuntimeError, #class_name "." #method_name "() - " BGE_PROXY_ERROR_MSG); return NULL; } \
                return ((class_name*)BGE_PROXY_REF(self))->Py##method_name();           \
        }; \
     static const char method_name##_doc[]; \