From c592ebf5df4a2be3b70bd3e2f2bba0e3d5908704 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 16 Nov 2013 22:10:27 +0000 Subject: Freestyle: a follow-up fix of trunk revision 61233. When an iterator has reached the end, any reference of the object pointed by it will now lead to a RuntimeError instead of returning None, with the aim of forcing Python API users to check the end of iteration rather than implicitly indicating the error condition. Acknowledgement to flokkievids for API discussions in the BlenderArtists.org Freestyle for Blender thread. --- .../freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp') diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp index 3174980b7d9..8287e280186 100644 --- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp +++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp @@ -109,8 +109,10 @@ PyDoc_STRVAR(StrokeVertexIterator_object_doc, static PyObject *StrokeVertexIterator_object_get(BPy_StrokeVertexIterator *self, void *UNUSED(closure)) { - if (!self->reversed && self->sv_it->isEnd()) - Py_RETURN_NONE; + if (!self->reversed && self->sv_it->isEnd()) { + PyErr_SetString(PyExc_RuntimeError, "iteration has stopped"); + return NULL; + } StrokeVertex *sv = self->sv_it->operator->(); if (sv) return BPy_StrokeVertex_from_StrokeVertex(*sv); -- cgit v1.2.3