Yury Selivanov added the comment: > This is a specific example of the general problem reported in issue 25538.
It's a bit different code path/problem. But I agree, we should work on making both `with` and `async with` a bit more usable. > Would it be possible to change this so it indicates that it was the context > that was invalid not an `await` statement? I'm not sure if we can do anything about this. We compile 'async with' into a set of opcodes. The first ones resolve __aexit__, the latter ones await on it. The one that prepares to await on the aexit (GET_AWAITABLE) is the same that 'await' expression compiles to, and that opcode has no idea what exactly it awaits on. We could probably add GET_AEXIT_AWAITABLE opcode specifically to improve the error message (other than that it would be a copy of GET_AWAITABLE). I'll think about it. ---------- assignee: -> yselivanov _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29922> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com