8000 tests/basics: Add test for throw into yield-from with normal return. · jimmo/micropython@27fe84e · GitHub
[go: up one dir, main page]

Skip to content

Commit 27fe84e

Browse files
committed
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.
1 parent 809d89c commit 27fe84e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/basics/gen_yield_from_throw.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,17 @@ def gen2():
3434
print(next(g))
3535
except TypeError:
3636
print("got TypeError from downstream!")
37+
38+
# thrown value is caught and then generator returns normally
39+
def gen():
40+
try:
41+
yield 123
42+
except ValueError:
43+
print('ValueError')
44+
# return normally after catching thrown exception
45+
def gen2():
46+
yield from gen()
47+
yield 789
48+
g = gen2()
49+
print(next(g))
50+
print(g.throw(ValueError))

0 commit comments

Comments
 (0)
0