[New-bugs-announce] [issue32703] 'async with' somehow suppresses unawaited coroutine warnings
report at bugs.python.org
Sun Jan 28 23:06:16 EST 2018
New submission from Nathaniel Smith <njs at pobox.com>:
Example (minimal version of https://github.com/python-trio/trio/issues/425):
async def open_file():
async def main():
async with open_file(): # Should be 'async with await open_file()'
coro = main()
Here we accidentally left out an 'await' on the call to 'open_file', so the 'async with' tries to look up 'CoroutineType.__aexit__', which obviously doesn't exist, and the program crashes with an AttributeError("__aexit__"). Yet weirdly, this doesn't trigger a warning about 'open_file' being unawaited. It should!
Yury's theory: maybe BEFORE_ASYNC_WITH's error-handling path is forgetting to DECREF the object.
nosy: asvetlov, giampaolo.rodola, njs, yselivanov
title: 'async with' somehow suppresses unawaited coroutine warnings
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce