Commit 1a9dad5c authored by Stefan Behnel's avatar Stefan Behnel

extend yield-from test

parent e7a92df0
......@@ -355,6 +355,7 @@ def __test_value_attribute_of_StopIteration_exception():
pex(e)
return trace
def test_exception_value_crash():
"""
>>> test_exception_value_crash()
......@@ -369,6 +370,50 @@ def test_exception_value_crash():
return [42]
return list(g1())
def test_return_none():
"""
>>> test_return_none()
['g2']
"""
# There used to be a refcount error in CPython when the return value
# stored in the StopIteration has a refcount of 1.
def g1():
yield from g2()
def g2():
yield "g2"
return None
return list(g1())
def test_finally_return_none(raise_exc=None):
"""
>>> gen = test_finally_return_none()
>>> next(gen)
'g2'
>>> next(gen)
Traceback (most recent call last):
StopIteration
>>> gen = test_finally_return_none()
>>> next(gen)
'g2'
>>> gen.throw(ValueError())
Traceback (most recent call last):
StopIteration
"""
# There used to be a refcount error in CPython when the return value
# stored in the StopIteration has a refcount of 1.
def g1():
yield from g2()
def g2():
try:
yield "g2"
finally:
return None
return g1()
def test_generator_return_value():
"""
>>> _lines(test_generator_return_value())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment