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>2010-11-07 07:46:50 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-11-07 07:46:50 +0300
commitc34275bcabc205a3cdc8abba8062ee84fd460850 (patch)
tree14adc1a93b8284d7eea1d82d9fc0a6552af76eef /source/blender/python
parent46f90690e029af46f8a321f1217e3e669d5bd5a0 (diff)
better exception check for calling operators. non dict/None values were being treated as None.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_operator.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source/blender/python/intern/bpy_operator.c b/source/blender/python/intern/bpy_operator.c
index f3e960f87b2..e78e79fd6a8 100644
--- a/source/blender/python/intern/bpy_operator.c
+++ b/source/blender/python/intern/bpy_operator.c
@@ -73,8 +73,13 @@ static PyObject *pyop_poll(PyObject *UNUSED(self), PyObject *args)
}
}
- if(!PyDict_Check(context_dict))
+ if(context_dict==NULL || context_dict==Py_None) {
context_dict= NULL;
+ }
+ else if (!PyDict_Check(context_dict)) {
+ PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s.poll\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name);
+ return NULL;
+ }
context_dict_back= CTX_py_dict_get(C);
@@ -130,8 +135,13 @@ static PyObject *pyop_call(PyObject *UNUSED(self), PyObject *args)
}
}
- if(!PyDict_Check(context_dict))
+ if(context_dict==NULL || context_dict==Py_None) {
context_dict= NULL;
+ }
+ else if (!PyDict_Check(context_dict)) {
+ PyErr_Format(PyExc_TypeError, "Calling operator \"bpy.ops.%s\" error, custom context expected a dict or None, got a %.200s", opname, Py_TYPE(context_dict)->tp_name);
+ return NULL;
+ }
context_dict_back= CTX_py_dict_get(C);