summaryrefslogtreecommitdiff
path: root/tests/basics/gen_yield_from_throw.py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-02-21 14:07:44 +1100
committerDamien George <damien.p.george@gmail.com>2019-05-09 13:40:28 +1000
commitdac9d4767175541aaaaf0e2f873322f5f1db3b0c (patch)
tree7ea2c8dcf3a26eaa1928f8a22b6800169dea7efc /tests/basics/gen_yield_from_throw.py
parent29865e3e58a89eace83fc1910221724363f55d64 (diff)
py/objgenerator: Fix handling of None passed as 2nd arg to throw().
Fixes issue #4527.
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!")