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
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-07-13 12:33:51 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-07-13 12:33:51 +0400
commit89830ea0c87765aea30bc2b69abe417ef941ea55 (patch)
tree2769de7ebaf585412210c8566c6d52a7fbc38fc8 /source/blender/python/intern
parent26ef6da24b3324fb6f8ab6cfe12f101f0d7dedb4 (diff)
calling operators from python was raising an error without returning an error value.
brecht, switched the order back to fix this, added an argument for WM_operatortype_find() to fail without printing an error.
Diffstat (limited to 'source/blender/python/intern')
-rw-r--r--source/blender/python/intern/bpy_operator.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index b183120dd2d..b57ef54304b 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -68,7 +68,7 @@ static PyObject *pyop_base_call( PyObject * self, PyObject * args, PyObject * k
return NULL;
}
- ot= WM_operatortype_find(opname);
+ ot= WM_operatortype_find(opname, 1);
if (ot == NULL) {
PyErr_Format( PyExc_SystemError, "Operator \"%s\"could not be found", opname);
return NULL;
@@ -130,12 +130,19 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
PyObject *ret;
wmOperatorType *ot;
- if ((ret = PyObject_GenericGetAttr((PyObject *)self, pyname))) {
- /* do nothing, this accounts for methoddef's add and remove */
- }
- else if ((ot= WM_operatortype_find(name))) {
+ /* First look for the operator, then our own methods if that fails.
+ * when methods are searched first, PyObject_GenericGetAttr will raise an error
+ * each time we want to call an operator, we could clear the error but I prefer
+ * not to since calling operators is a lot more common then adding and removing. - Campbell */
+
+ if ((ot= WM_operatortype_find(name, 1))) {
ret = PyCFunction_New( pyop_base_call_meth, pyname); /* set the name string as self, PyCFunction_New incref's self */
}
+ else if ((ret = PyObject_GenericGetAttr((PyObject *)self, pyname))) {
+ /* do nothing, this accounts for methoddef's add and remove
+ * An exception is raised when PyObject_GenericGetAttr fails
+ * but its ok because its overwritten below */
+ }
else {
PyErr_Format( PyExc_AttributeError, "Operator \"%s\" not found", name);
ret= NULL;
@@ -170,7 +177,7 @@ static PyObject *pyop_base_rna(PyObject *self, PyObject *pyname)
char *name = _PyUnicode_AsString(pyname);
wmOperatorType *ot;
- if ((ot= WM_operatortype_find(name))) {
+ if ((ot= WM_operatortype_find(name, 1))) {
BPy_StructRNA *pyrna;
PointerRNA ptr;