summaryrefslogtreecommitdiff
path: root/tests/basics/gen_yield_from_throw.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/basics/gen_yield_from_throw.py')
-rw-r--r--tests/basics/gen_yield_from_throw.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/basics/gen_yield_from_throw.py b/tests/basics/gen_yield_from_throw.py
index 703158f4d..804c53dda 100644
--- a/tests/basics/gen_yield_from_throw.py
+++ b/tests/basics/gen_yield_from_throw.py
@@ -1,8 +1,8 @@
def gen():
try:
yield 1
- except ValueError:
- print("got ValueError from upstream!")
+ except ValueError as e:
+ print("got ValueError from upstream!", repr(e.args))
yield "str1"
raise TypeError
@@ -16,3 +16,21 @@ try:
print(next(g))
except TypeError:
print("got TypeError from downstream!")
+
+# passing None as second argument to throw
+g = gen2()
+print(next(g))
+print(g.throw(ValueError, None))
+try:
+ print(next(g))
+except TypeError:
+ print("got TypeError from downstream!")
+
+# passing an exception instance as second argument to throw
+g = gen2()
+print(next(g))
+print(g.throw(ValueError, ValueError(123)))
+try:
+ print(next(g))
+except TypeError:
+ print("got TypeError from downstream!")