[Python-ideas] Map and filter should also convert StopIteration to RuntimeError
rosuav at gmail.com
Tue Dec 16 00:05:07 CET 2014
On Tue, Dec 16, 2014 at 4:37 AM, <random832 at fastmail.us> wrote:
> It's worth mentioning that #2 is, more or less,* precisely how both map
> and a pure-python equivalent behaved before PEP 479. Some people in this
> discussion considered this expected. Obviously that was not the end of
> the discussion.
> *Assuming that the code consuming the outer iterator will not attempt to
> read it again after a single StopIteration has been raised. A
> well-behaved iterator will continue to raise StopIteration forever after
> it has raised it once - an iterator whose StopIteration has been caused
> by some inner function will not.
Right, and it's that assumption that's the entire question here. This
is buggy behaviour; the question is, is the bug map's problem (because
it's failing to behave the way an iterator should), or is it simply a
bug in the called function, which shouldn't be raising StopIteration?
More information about the Python-ideas