[issue32703] 'async with' somehow suppresses unawaited coroutine warnings
Nathaniel Smith
report at bugs.python.org
Sun Jan 28 23:10:22 EST 2018
Nathaniel Smith <njs at pobox.com> added the comment:
> Yury's theory: maybe BEFORE_ASYNC_WITH's error-handling path is forgetting to DECREF the object.
Nope, that doesn't seem to be it. This version prints "refcount: 2" twice, *and* prints a proper "was never awaited" warning:
-----
import sys
async def open_file():
pass
async def main():
open_file_coro = open_file()
print("refcount:", sys.getrefcount(open_file_coro))
try:
async with open_file_coro:
pass
except:
pass
print("refcount:", sys.getrefcount(open_file_coro))
coro = main()
try:
coro.send(None)
except:
pass
----------
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32703>
_______________________________________
More information about the Python-bugs-list
mailing list