py/objgenerator: Fix handling of None passed as 2nd arg to throw().

Fixes issue #4527.
This commit is contained in:
Damien George
2019-02-21 14:07:44 +11:00
parent 29865e3e58
commit dac9d47671
3 changed files with 48 additions and 5 deletions

View File

@@ -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!")