Tadhg McDonald-Jensen added the comment: > This is a specific example of the general problem reported in issue 25538.
Definitely related, although the part of giving an error "... can't be used in 'await' expression" when no await expression is used isn't covered by that thread so I'm not sure I'd call this a direct duplicate. Currently when __anext__ return a non-awaitable this error is shown: TypeError: 'async for' received an invalid object from __anext__: NoneType So having __aenter__ and __aexit__ have similar error messages would be nice. Would it maybe make sense to implement this as adding an argument to GET_AWAITABLE to indicate whether it was called from await, __anext__, __aenter__ or __aexit__? (or others that may exist in future) I don't know enough about bytecode to know how it'd compare to an instruction for each case. ---------- _______________________________________ 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