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-11-23 00:51:12 +0300
committerCampbell Barton <ideasman42@gmail.com>2009-11-23 00:51:12 +0300
commitdc5b0c8b9c78a0c251f2ed2eacff7deffd70bd6a (patch)
treedb52f416b03a82eda86c42865b7f5a965472220d /source/blender/python
parent9c602bd4554a2ad6b49c261830cf72e8849ade16 (diff)
rna functions were getting away with passing the string "True" instead of True, changed get the integer value and test its 1 or 0.
allow rna function return values as an exception since so many poll functions do... "return (context.blah and context.foo)", that makign all return bool's isnt that nice.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/intern/bpy_rna.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c
index d25a240990b..cdf4f518b51 100644
--- a/source/blender/python/intern/bpy_rna.c
+++ b/source/blender/python/intern/bpy_rna.c
@@ -591,9 +591,16 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v
switch (type) {
case PROP_BOOLEAN:
{
- int param = PyObject_IsTrue( value );
+ int param;
+ /* prefer not to have an exception here
+ * however so many poll functions return None or a valid Object.
+ * its a hassle to convert these into a bool before returning, */
+ if(RNA_property_flag(prop) & PROP_RETURN)
+ param = PyObject_IsTrue( value );
+ else
+ param = PyLong_AsSsize_t( value );
- if( param < 0 ) {
+ if( param < 0 || param > 1) {
PyErr_Format(PyExc_TypeError, "%.200s expected True/False or 0/1", error_prefix);
return -1;
} else {
@@ -681,7 +688,7 @@ int pyrna_py_to_prop(PointerRNA *ptr, PropertyRNA *prop, void *data, PyObject *v
PyErr_Format(PyExc_TypeError, "%.200s expected a %.200s type", error_prefix, RNA_struct_identifier(ptype));
return -1;
} else if((flag & PROP_NEVER_NULL) && value == Py_None) {
- PyErr_Format(PyExc_TypeError, "property can't be assigned a None value");
+ PyErr_Format(PyExc_TypeError, "%.200s does not suppory a 'None' assignment %.200s type", error_prefix, RNA_struct_identifier(ptype));
return -1;
} else {
BPy_StructRNA *param= (BPy_StructRNA*)value;
@@ -813,9 +820,9 @@ static int pyrna_py_to_prop_index(BPy_PropertyRNA *self, int index, PyObject *va
switch (type) {
case PROP_BOOLEAN:
{
- int param = PyObject_IsTrue( value );
+ int param = PyLong_AsSsize_t( value );
- if( param < 0 ) {
+ if( param < 0 || param > 1) {
PyErr_SetString(PyExc_TypeError, "expected True/False or 0/1");
ret = -1;
} else {