fix for py/rna mesh.materials[:] where empty materials exist, would raise a runtime exception.

problem was there was no way to tell the difference between getting an empty item from a collection or the item not being found.
This commit is contained in:
2011-01-05 14:49:08 +00:00
parent 26024445ac
commit 978bc0d8ac
8 changed files with 50 additions and 43 deletions

View File

@@ -1422,8 +1422,9 @@ static PyObject *pyrna_prop_collection_subscript_int(BPy_PropertyRNA *self, Py_s
if(RNA_property_collection_lookup_int(&self->ptr, self->prop, keynum, &newptr)) {
return pyrna_struct_CreatePyObject(&newptr);
}
else { /* fail's if ptr.data == NULL, valid for mesh.materials */
Py_RETURN_NONE;
else {
PyErr_SetString(PyExc_RuntimeError, "error getting an rna struct from a collection");
return NULL;
}
}
PyErr_Format(PyExc_IndexError, "bpy_prop_collection[index]: index %d out of range, size %d", keynum, len);