Author: Armin Rigo <ar...@tunes.org> Branch: py3.5-corowrapper Changeset: r87200:8abd37f94fd0 Date: 2016-09-17 23:07 +0200 http://bitbucket.org/pypy/pypy/changeset/8abd37f94fd0/
Log: Test and fix diff --git a/pypy/interpreter/generator.py b/pypy/interpreter/generator.py --- a/pypy/interpreter/generator.py +++ b/pypy/interpreter/generator.py @@ -499,9 +499,9 @@ w_await = space.lookup(w_obj, "__await__") if w_await is None: - raise oefmt(space.w_AttributeError, - "object %T can't be used in 'await' expression" - " (no __await__ method)", w_obj) + raise oefmt(space.w_TypeError, + "object %T can't be used in 'await' expression", + w_obj) w_res = space.get_and_call_function(w_await, w_obj) if isinstance(w_res, Coroutine) or gen_is_coroutine(w_res): raise oefmt(space.w_TypeError, 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 @@ -104,3 +104,15 @@ assert c.send(82) == 41 raises(StopIteration, c.send, 93) """ + + def test_await_error(self): """ + async def f(): + await [42] + c = f() + try: + c.send(None) + except TypeError as e: + assert str(e) == "object list can't be used in 'await' expression" + else: + assert False, "should have raised" + """ _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit