On Tue, Nov 25, 2014 at 9:30 AM, Wolfgang Maier < email@example.com> wrote:
allow StopIteration to be raised anywhere, but let it bubble up only *one* frame. So if the next outer frame does not deal with it, the exception would be converted to UnhandledStopIteration (or something else) when it's about to bubble out of that outer frame. The builtin next() would simply reset the frame count by catching and reraising StopIteration raised inside its argument (whether that's an iterator's __next__ or a generator; note that in this scenario using raise StopIteration instead of return inside a generator would remain possible).
I also have no idea if this is practical from an implementation perspective, but I like how it support my goal of keeping the behavior of iterator classes and generators consistent.