From 27fe84e661d664c5c145b4b3a8d544dad7de0acb Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 4 Oct 2019 22:58:43 +1000 Subject: [PATCH] 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. --- tests/basics/gen_yield_from_throw.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/basics/gen_yield_from_throw.py b/tests/basics/gen_yield_from_throw.py index 804c53dda0..1f76e13f3c 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))