Author: Armin Rigo <[email protected]>
Branch: py3.6
Changeset: r94931:77bcaf8bbc5f
Date: 2018-07-29 15:43 +0000
http://bitbucket.org/pypy/pypy/changeset/77bcaf8bbc5f/
Log: Merged in raduciorba/pypy/py3.6 (pull request #619)
fix async generator bug when yielding a StopIteration
diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py
--- a/pypy/interpreter/generator.py
+++ b/pypy/interpreter/generator.py
@@ -199,7 +199,6 @@
except OperationError as e:
if not e.match(space, space.w_StopIteration):
raise
- e.normalize_exception(space)
frame._report_stopiteration_sometimes(w_yf, e)
try:
w_stop_value = space.getattr(e.get_w_value(space),
@@ -679,11 +678,8 @@
def unwrap_value(self, w_value):
if isinstance(w_value, AsyncGenValueWrapper):
- w_value = w_value.w_value
- if self.space.isinstance_w(w_value, self.space.w_tuple):
- # Construct the exception manually, to avoid tuple unpacking.
- w_value = self.space.call_function(self.space.w_StopIteration,
- w_value)
+ w_value = self.space.call_function(self.space.w_StopIteration,
+ w_value.w_value)
raise OperationError(self.space.w_StopIteration, w_value)
else:
return w_value
diff --git a/pypy/interpreter/test/test_coroutine.py
b/pypy/interpreter/test/test_coroutine.py
--- a/pypy/interpreter/test/test_coroutine.py
+++ b/pypy/interpreter/test/test_coroutine.py
@@ -671,3 +671,20 @@
assert self.run_async(run()) == ([], (1,))
"""
+
+ def test_asyncgen_yield_stopiteration(self):
+ """
+ async def foo():
+ yield 1
+ yield StopIteration(2)
+
+ async def run():
+ it = foo().__aiter__()
+ val1 = await it.__anext__()
+ assert val1 == 1
+ val2 = await it.__anext__()
+ assert isinstance(val2, StopIteration)
+ assert val2.value == 2
+
+ self.run_async(run())
+ """
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit