diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-03 19:07:49 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2013-03-03 19:07:49 +0400 |
commit | 66a2b848972d47a033f617a40f9a9044756d1d32 (patch) | |
tree | bf30f5bc13e9c0b4f52aacead676a2c07cbb331a /source/blender/python | |
parent | 0c5dfc8a639b04e1767852121b9dee7cd5bb050f (diff) | |
parent | 4774357b594c5cd5a38b21df131b539a197c101b (diff) |
Merged changes in the trunk up to revision 54992.
Resolved conflicts:
release/scripts/startup/bl_ui/space_view3d.py
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/intern/bpy_rna.c | 33 | ||||
-rw-r--r-- | source/blender/python/intern/bpy_rna_anim.c | 3 |
2 files changed, 28 insertions, 8 deletions
diff --git a/source/blender/python/intern/bpy_rna.c b/source/blender/python/intern/bpy_rna.c index 19ec35ae357..cef4e23242d 100644 --- a/source/blender/python/intern/bpy_rna.c +++ b/source/blender/python/intern/bpy_rna.c @@ -4257,11 +4257,12 @@ static PyObject *pyrna_prop_collection_find(BPy_PropertyRNA *self, PyObject *key return PyLong_FromLong(index); } -static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr, +static bool foreach_attr_type(BPy_PropertyRNA *self, const char *attr, /* values to assign */ RawPropertyType *raw_type, int *attr_tot, bool *attr_signed) { PropertyRNA *prop; + bool attr_ok = true; *raw_type = PROP_RAW_UNSET; *attr_tot = 0; *attr_signed = false; @@ -4270,12 +4271,19 @@ static void foreach_attr_type(BPy_PropertyRNA *self, const char *attr, RNA_PROP_BEGIN (&self->ptr, itemptr, self->prop) { prop = RNA_struct_find_property(&itemptr, attr); - *raw_type = RNA_property_raw_type(prop); - *attr_tot = RNA_property_array_length(&itemptr, prop); - *attr_signed = (RNA_property_subtype(prop) == PROP_UNSIGNED) ? false : true; + if (prop) { + *raw_type = RNA_property_raw_type(prop); + *attr_tot = RNA_property_array_length(&itemptr, prop); + *attr_signed = (RNA_property_subtype(prop) != PROP_UNSIGNED); + } + else { + attr_ok = false; + } break; } RNA_PROP_END; + + return attr_ok; } /* pyrna_prop_collection_foreach_get/set both use this */ @@ -4295,15 +4303,26 @@ static int foreach_parse_args(BPy_PropertyRNA *self, PyObject *args, *attr_signed = false; *raw_type = PROP_RAW_UNSET; - if (!PyArg_ParseTuple(args, "sO", attr, seq) || (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq))) { - PyErr_SetString(PyExc_TypeError, "foreach_get(attr, sequence) expects a string and a sequence"); + if (!PyArg_ParseTuple(args, "sO:foreach_get/set", attr, seq)) { + return -1; + } + + if (!PySequence_Check(*seq) && PyObject_CheckBuffer(*seq)) { + PyErr_Format(PyExc_TypeError, + "foreach_get/set expected second argument to be a sequence or buffer, not a %.200s", + Py_TYPE(seq)->tp_name); return -1; } *tot = PySequence_Size(*seq); /* TODO - buffer may not be a sequence! array.array() is tho. */ if (*tot > 0) { - foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed); + if (!foreach_attr_type(self, *attr, raw_type, attr_tot, attr_signed)) { + PyErr_Format(PyExc_AttributeError, + "foreach_get/set '%.200s.%200s[...]' elements have no attribute '%.200s'", + RNA_struct_identifier(self->ptr.type), RNA_property_identifier(self->prop), *attr); + return -1; + } *size = RNA_raw_type_sizeof(*raw_type); #if 0 /* works fine but not strictly needed, we could allow RNA_property_collection_raw_* to do the checks */ diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index a19f8e2d8ed..b61ed55da06 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -156,7 +156,8 @@ static int pyrna_struct_keyframe_parse( /* note, parse_str MUST start with 's|ifsO!' */ if (!PyArg_ParseTupleAndKeywords(args, kw, parse_str, (char **)kwlist, &path, index, cfra, group_name, - &PySet_Type, &pyoptions)) { + &PySet_Type, &pyoptions)) + { return -1; } |