[Bf-committers] [Bf-blender-cvs] [c592ebf] master: Freestyle: a follow-up fix of trunk revision 61233.

Tamito KAJIYAMA rd6t-kjym at asahi-net.or.jp
Sun Nov 17 18:20:36 CET 2013


Hi Campbell,

In the Freestyle Python API, StopIteration is used to implement the 
generic Python iterator protocol.  In addition, the API allows users to 
increment an iterator manually through the iterator's .increment() 
method.  When the iteration is over N elements, manual iteration ends 
after N increment operations and the iterator points one after the last 
element.  At this point of time any reference of the object pointed by 
the iterator (e.g., by calling the .object() method to retrieve the 
object) is considered an error.  The idea behind the code revision is to 
indicate this error condition by raising an exception.

I was indeed wondering what would be the most appropriate exception 
class in this specific case.  I was not sure if StopIteration is 
intended for this kind of situations, so I ended up in choosing 
RuntimeError.  Any suggestion would be much appreciated.

Thanks,

-- 
KAJIYAMA, Tamito <rd6t-kjym at asahi-net.or.jp>


On 17/11/2013 04:07, Campbell Barton wrote:
> 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
> <noreply at 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.


More information about the Bf-committers mailing list