Chris Angelico added the comment:

Yep, the question is whether any of the "raise StopIteration" lines are 
actually non-local flow control. If they're local, then it's easy: mechanical 
replacement with "return" and it becomes compatible with all versions (unless 
it has a value attached to it, as "return x" doesn't work in Py2). But if 
they're non-local, some refactoring will need to be done.

In any case, my line of argument is: A generator function is not an iterator's 
__next__ method, ergo iterator protocol does not apply. Use of StopIteration is 
a hack that happens to work because of how generator functions are implemented 
(a thin wrapper around an iterator), but it's not part of the *concept* of a 
generator function.


Python tracker <>
Python-bugs-list mailing list

Reply via email to