Author: Armin Rigo <ar...@tunes.org> Branch: py3.5-corowrapper Changeset: r87188:42c3a9990f34 Date: 2016-09-17 19:52 +0200 http://bitbucket.org/pypy/pypy/changeset/42c3a9990f34/
Log: Test and fix diff --git a/pypy/interpreter/pyopcode.py b/pypy/interpreter/pyopcode.py --- a/pypy/interpreter/pyopcode.py +++ b/pypy/interpreter/pyopcode.py @@ -1505,7 +1505,8 @@ u"'%s' implements legacy __aiter__ protocol; " u"__aiter__ should return an asynchronous " u"iterator, not awaitable" % - space.type(w_obj).name.decode('utf-8'))) + space.type(w_obj).name.decode('utf-8')), + space.w_PendingDeprecationWarning) self.pushvalue(w_awaitable) def GET_ANEXT(self, oparg, next_instr): 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 @@ -31,3 +31,21 @@ else: assert False, "should have raised" """ + + def test_async_for_old_style(self): """ + class X: + def __aiter__(self): + return MyAIter() + class MyAIter: + def __await__(self): + return iter([20, 30]) + async def f(x): + sum = 0 + async for a in x: + sum += a + if sum > 100: + break + return sum + cr = f(X()) + assert next(cr.__await__()) == 20 + """ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit