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

@@ -28,8 +28,8 @@ except StopIteration:
def gen():
try:
yield 123
except GeneratorExit:
print('GeneratorExit')
except GeneratorExit as e:
print('GeneratorExit', repr(e.args))
yield 456
# thrown a class
@@ -41,3 +41,13 @@ print(g.throw(GeneratorExit))
g = gen()
print(next(g))
print(g.throw(GeneratorExit()))
# thrown an instance with None as second arg
g = gen()
print(next(g))
print(g.throw(GeneratorExit(), None))
# thrown a class and instance
g = gen()
print(next(g))
print(g.throw(GeneratorExit, GeneratorExit(123)))