fix for py/rna mesh.materials[:] where empty materials exist, would raise a runtime...
[blender-staging.git] / source / blender / python / intern / bpy_rna.c
index 123091cf6df4b92c9ce856b1db1410f863acbe5f..fb6bfe8a86d7eea313470590a8ac7c85b4c13c1d 100644 (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);