diff options
author | Damien George <damien.p.george@gmail.com> | 2019-10-04 22:58:43 +1000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-10-04 23:27:48 +1000 |
commit | 27fe84e661d664c5c145b4b3a8d544dad7de0acb (patch) | |
tree | 998b187eb8168d6ee5e93fe51c004a19de39b8b4 | |
parent | 809d89c794ceb44760ab997ff9a496488b4a2c0c (diff) |
tests/basics: Add test for throw into yield-from with normal return.
This test was found by missing coverage of a branch in py/nativeglue.c.
-rw-r--r-- | tests/basics/gen_yield_from_throw.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/basics/gen_yield_from_throw.py b/tests/basics/gen_yield_from_throw.py index 804c53dda..1f76e13f3 100644 --- a/tests/basics/gen_yield_from_throw.py +++ b/tests/basics/gen_yield_from_throw.py @@ -34,3 +34,17 @@ try: print(next(g)) except TypeError: print("got TypeError from downstream!") + +# thrown value is caught and then generator returns normally +def gen(): + try: + yield 123 + except ValueError: + print('ValueError') + # return normally after catching thrown exception +def gen2(): + yield from gen() + yield 789 +g = gen2() +print(next(g)) +print(g.throw(ValueError)) |