Is there a reason to use PyExc_RuntimeError?, other parts of
freestyles code use: PyErr_SetNone(PyExc_StopIteration);

On Sun, Nov 17, 2013 at 9:12 AM, Tamito Kajiyama
<nore...@git.blender.org> wrote:
> Commit: c592ebf5df4a2be3b70bd3e2f2bba0e3d5908704
> Author: Tamito Kajiyama
> Date:   Sat Nov 16 22:10:27 2013 +0000
> http://developer.blender.org/rBc592ebf5df4a2be3b70bd3e2f2bba0e3d5908704
>
> 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.
>
> ===================================================================
>
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
> M       
> source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
>
> ===================================================================
>
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
> index 0daaa1a0..2927297 100644
> --- 
> a/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
> +++ 
> b/source/blender/freestyle/intern/python/Iterator/BPy_AdjacencyIterator.cpp
> @@ -115,8 +115,10 @@ PyDoc_STRVAR(AdjacencyIterator_object_doc,
>
>  static PyObject *AdjacencyIterator_object_get(BPy_AdjacencyIterator *self, 
> void *UNUSED(closure))
>  {
> -       if (self->a_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (self->a_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         ViewEdge *ve = self->a_it->operator*();
>         if (ve)
>                 return BPy_ViewEdge_from_ViewEdge(*ve);
> @@ -131,6 +133,10 @@ PyDoc_STRVAR(AdjacencyIterator_is_incoming_doc,
>
>  static PyObject *AdjacencyIterator_is_incoming_get(BPy_AdjacencyIterator 
> *self, void *UNUSED(closure))
>  {
> +       if (self->a_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         return PyBool_from_bool(self->a_it->isIncoming());
>  }
>
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
> index 91e8de1..9a4eb2b 100644
> --- a/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
> +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ChainingIterator.cpp
> @@ -175,8 +175,10 @@ PyDoc_STRVAR(ChainingIterator_object_doc,
>
>  static PyObject *ChainingIterator_object_get(BPy_ChainingIterator *self, 
> void *UNUSED(closure))
>  {
> -       if (self->c_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (self->c_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         ViewEdge *ve = self->c_it->operator*();
>         if (ve)
>                 return BPy_ViewEdge_from_ViewEdge(*ve);
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
> index 1655b76..0329aa9 100644
> --- 
> a/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
> +++ 
> b/source/blender/freestyle/intern/python/Iterator/BPy_CurvePointIterator.cpp
> @@ -97,8 +97,10 @@ PyDoc_STRVAR(CurvePointIterator_object_doc,
>
>  static PyObject *CurvePointIterator_object_get(BPy_CurvePointIterator *self, 
> void *UNUSED(closure))
>  {
> -       if (self->cp_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (self->cp_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         return BPy_CurvePoint_from_CurvePoint(self->cp_it->operator*());
>  }
>
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
> index 2f6c8ff..3a24626 100644
> --- 
> a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
> +++ 
> b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
> @@ -123,8 +123,10 @@ PyDoc_STRVAR(Interface0DIterator_object_doc,
>
>  static PyObject *Interface0DIterator_object_get(BPy_Interface0DIterator 
> *self, void *UNUSED(closure))
>  {
> -       if (self->if0D_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (self->if0D_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         return 
> Any_BPy_Interface0D_from_Interface0D(self->if0D_it->operator*());
>  }
>
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
> index d493b6c..ccf52c6 100644
> --- a/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
> +++ b/source/blender/freestyle/intern/python/Iterator/BPy_SVertexIterator.cpp
> @@ -115,6 +115,10 @@ PyDoc_STRVAR(SVertexIterator_object_doc,
>
>  static PyObject *SVertexIterator_object_get(BPy_SVertexIterator *self, void 
> *UNUSED(closure))
>  {
> +       if (self->sv_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         SVertex *sv = self->sv_it->operator->();
>         if (sv)
>                 return BPy_SVertex_from_SVertex(*sv);
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
>  
> b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
> index 3174980..8287e28 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);
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp 
> b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
> index c191a94..87e05a7 100644
> --- a/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
> +++ b/source/blender/freestyle/intern/python/Iterator/BPy_ViewEdgeIterator.cpp
> @@ -122,8 +122,10 @@ PyDoc_STRVAR(ViewEdgeIterator_object_doc,
>
>  static PyObject *ViewEdgeIterator_object_get(BPy_ViewEdgeIterator *self, 
> void *UNUSED(closure))
>  {
> -       if (!self->ve_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (!self->ve_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         ViewEdge *ve = self->ve_it->operator*();
>         if (ve)
>                 return BPy_ViewEdge_from_ViewEdge(*ve);
> @@ -140,7 +142,8 @@ static PyObject 
> *ViewEdgeIterator_current_edge_get(BPy_ViewEdgeIterator *self, v
>         ViewEdge *ve = self->ve_it->getCurrentEdge();
>         if (ve)
>                 return BPy_ViewEdge_from_ViewEdge(*ve);
> -       Py_RETURN_NONE;}
> +       Py_RETURN_NONE;
> +}
>
>  static int ViewEdgeIterator_current_edge_set(BPy_ViewEdgeIterator *self, 
> PyObject *value, void *UNUSED(closure))
>  {
> diff --git 
> a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
>  
> b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
> index cbefcd3..12ca3d6 100644
> --- 
> a/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
> +++ 
> b/source/blender/freestyle/intern/python/Iterator/BPy_orientedViewEdgeIterator.cpp
> @@ -103,8 +103,10 @@ PyDoc_STRVAR(orientedViewEdgeIterator_object_doc,
>
>  static PyObject 
> *orientedViewEdgeIterator_object_get(BPy_orientedViewEdgeIterator *self, void 
> *UNUSED(closure))
>  {
> -       if (self->ove_it->isEnd())
> -               Py_RETURN_NONE;
> +       if (self->ove_it->isEnd()) {
> +               PyErr_SetString(PyExc_RuntimeError, "iteration has stopped");
> +               return NULL;
> +       }
>         return 
> BPy_directedViewEdge_from_directedViewEdge(self->ove_it->operator*());
>  }
>
> _______________________________________________
> Bf-blender-cvs mailing list
> bf-blender-...@blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs



-- 
- Campbell
_______________________________________________
Bf-committers mailing list
Bf-committers@blender.org
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to