[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34950] trunk/blender/source: py api was raising SystemError exception incorrectly, this is intended for internal interpreter problems.
Campbell Barton
ideasman42 at gmail.com
Fri Feb 18 07:04:06 CET 2011
Revision: 34950
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34950
Author: campbellbarton
Date: 2011-02-18 06:04:05 +0000 (Fri, 18 Feb 2011)
Log Message:
-----------
py api was raising SystemError exception incorrectly, this is intended for internal interpreter problems.
Replace most with RuntimeError.
Modified Paths:
--------------
trunk/blender/source/blender/python/generic/mathutils.c
trunk/blender/source/blender/python/generic/py_capi_utils.c
trunk/blender/source/blender/python/intern/bpy_interface.c
trunk/blender/source/blender/python/intern/bpy_operator.c
trunk/blender/source/blender/python/intern/bpy_props.c
trunk/blender/source/blender/python/intern/bpy_rna.c
trunk/blender/source/blender/python/intern/bpy_util.c
trunk/blender/source/gameengine/Expressions/PyObjectPlus.h
Modified: trunk/blender/source/blender/python/generic/mathutils.c
===================================================================
--- trunk/blender/source/blender/python/generic/mathutils.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/generic/mathutils.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -273,7 +273,7 @@
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 @@
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 @@
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 @@
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;
}
Modified: trunk/blender/source/blender/python/generic/py_capi_utils.c
===================================================================
--- trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/generic/py_capi_utils.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -78,7 +78,7 @@
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 @@
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;
}
Modified: trunk/blender/source/blender/python/intern/bpy_interface.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_interface.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/intern/bpy_interface.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -400,7 +400,7 @@
#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;
}
}
Modified: trunk/blender/source/blender/python/intern/bpy_operator.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_operator.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/intern/bpy_operator.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -60,7 +60,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
}
Modified: trunk/blender/source/blender/python/intern/bpy_props.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_props.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/intern/bpy_props.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -752,7 +752,7 @@
}
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;
}
Modified: trunk/blender/source/blender/python/intern/bpy_rna.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_rna.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/intern/bpy_rna.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -567,7 +567,7 @@
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 @@
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 @@
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 @@
}
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 @@
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;
}
}
Modified: trunk/blender/source/blender/python/intern/bpy_util.c
===================================================================
--- trunk/blender/source/blender/python/intern/bpy_util.c 2011-02-18 00:40:15 UTC (rev 34949)
+++ trunk/blender/source/blender/python/intern/bpy_util.c 2011-02-18 06:04:05 UTC (rev 34950)
@@ -151,7 +151,7 @@
}
if(report_str) {
- PyErr_SetString(PyExc_SystemError, report_str);
+ PyErr_SetString(PyExc_RuntimeError, report_str);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list