[Python-Dev] Inconsistency between PEP492, documentation and behaviour of "async with"
damien.p.george at gmail.com
Mon Jun 19 02:35:45 EDT 2017
Regarding the behaviour of the "async with" statement: it seems that the
description of it in PEP492, and the language documentation, do not match
the behaviour of CPython (v3.6.1).
The PEP and the docs here:
say that "async with" is equivalent to a particular use of try/except/else.
But the implementation seems more like a try/except/finally, because the
__aexit__ is always executed, even if a return statement is in the try
block ("else" won't be executed if there's a "return" in the "try"). Also,
as per normal "with", the implementation is a bit more complex than
try/except/finally because you don't want to execute the __aexit__ method
twice if there is an exception in the try.
Can someone please clarify the exact behaviour of "async with"?
Background: in implementing "async with" in MicroPython, we went by the
PEP/docs, and now our behaviour doesn't match that of CPython.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-Dev