diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-07-08 05:28:43 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-07-08 05:28:43 +0400 |
commit | 37d1984c53870c28c3c27165cba11f4f039706af (patch) | |
tree | 36afa1f83ff0ded182b015e87d0dc4e269096c53 /source/blender/python/intern/bpy_rna_array.c | |
parent | 2c8087aa2a9853f9caabc052b2e753c28704172b (diff) |
edit on own commit r57801, don't check the size of dynamic arrays
Diffstat (limited to 'source/blender/python/intern/bpy_rna_array.c')
-rw-r--r-- | source/blender/python/intern/bpy_rna_array.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index ee5f6109ab8..b8907e797ef 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -66,7 +66,7 @@ typedef void (*RNA_SetIndexFunc)(PointerRNA *, PropertyRNA *, int index, void *) /* arr[3] = x, self->arraydim is 0, lvalue_dim is 1 */ /* Ensures that a python sequence has expected number of items/sub-items and items are of desired type. */ -static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[], +static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[], const bool is_dynamic, ItemTypeCheckFunc check_item_type, const char *item_type_str, const char *error_prefix) { Py_ssize_t i; @@ -110,7 +110,9 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[] error_prefix, dim + 1, dimsize[dim + 1], item_seq_size); ok = 0; } - else if (validate_array_type(item, dim + 1, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) { + else if (validate_array_type(item, dim + 1, totdim, dimsize, is_dynamic, + check_item_type, item_type_str, error_prefix) == -1) + { ok = 0; } @@ -129,7 +131,7 @@ static int validate_array_type(PyObject *seq, int dim, int totdim, int dimsize[] error_prefix, dim + 1, Py_TYPE(seq)->tp_name); return -1; } - else if (seq_size != dimsize[dim]) { + else if ((seq_size != dimsize[dim]) && (is_dynamic == false)) { PyErr_Format(PyExc_ValueError, "%s sequences of dimension %d should contain %d items, not %d", error_prefix, dim, dimsize[dim], seq_size); return -1; @@ -315,8 +317,12 @@ static int validate_array(PyObject *rvalue, PointerRNA *ptr, PropertyRNA *prop, { - if (validate_array_type(rvalue, lvalue_dim, totdim, dimsize, check_item_type, item_type_str, error_prefix) == -1) + const int prop_flag = RNA_property_flag(prop); + if (validate_array_type(rvalue, lvalue_dim, totdim, dimsize, (prop_flag & PROP_DYNAMIC) != 0, + check_item_type, item_type_str, error_prefix) == -1) + { return -1; + } return validate_array_length(rvalue, ptr, prop, lvalue_dim, totitem, error_prefix); } |