[issue22906] PEP 479: Change StopIteration handling inside generators

John report at bugs.python.org
Tue Oct 6 16:26:25 EDT 2015


John added the comment:

Consider the following generator function similar to the one that started this issue:

    from __future__ import generator_stop

    def myzip(*seqs):
        its = (iter(seq) for seq in seqs)
        while True:
            try:        
                yield tuple(next(it) for it in its)
            except RuntimeError:
                return

    g = myzip('abc', 'xyz')
    print([next(g) for i in range(5)]) # prints: [('a', 'x'), (), (), (), ()]

A print(list(g)) would cause a hang.

----------
nosy: +john.black.3k

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22906>
_______________________________________


More information about the Python-bugs-list mailing list