diff options
author | Damien George <damien.p.george@gmail.com> | 2018-09-14 00:44:06 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2018-09-20 15:36:59 +1000 |
commit | 3f6ffe059f64b3ebc44dc0bbc63452cb8850702b (patch) | |
tree | 5bf2fe77ad624afccd08011ab05b19ab321b5d9c /tests/basics/gen_yield_from.py | |
parent | 17f7c683d2790880ec9da70f7bc7e40c490c8796 (diff) |
py/objgenerator: Implement PEP479, StopIteration convs to RuntimeError.
This commit implements PEP479 which disallows raising StopIteration inside
a generator to signal that it should be finished. Instead, the generator
should simply return when it is complete.
See https://www.python.org/dev/peps/pep-0479/ for details.
Diffstat (limited to 'tests/basics/gen_yield_from.py')
-rw-r--r-- | tests/basics/gen_yield_from.py | 28 |
1 files changed, 0 insertions, 28 deletions
diff --git a/tests/basics/gen_yield_from.py b/tests/basics/gen_yield_from.py index 4e68aec63..037644e1e 100644 --- a/tests/basics/gen_yield_from.py +++ b/tests/basics/gen_yield_from.py @@ -13,34 +13,6 @@ g = gen2() print(list(g)) -# Like above, but terminate subgen using StopIteration -def gen3(): - yield 1 - yield 2 - raise StopIteration - -def gen4(): - print("here1") - print((yield from gen3())) - print("here2") - -g = gen4() -print(list(g)) - -# Like above, but terminate subgen using StopIteration with value -def gen5(): - yield 1 - yield 2 - raise StopIteration(123) - -def gen6(): - print("here1") - print((yield from gen5())) - print("here2") - -g = gen6() -print(list(g)) - # StopIteration from within a Python function, within a native iterator (map), within a yield from def gen7(x): if x < 3: |