classification
Title: Incorrect description of "async with" in PEP492 and documentation
Type: behavior Stage:
Components: Documentation Versions: Python 3.7, Python 3.6, Python 3.5
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Damien George, docs@python, ncoghlan, yselivanov
Priority: normal Keywords:

Created on 2017-06-20 04:34 by Damien George, last changed 2017-06-20 05:38 by ncoghlan.

Messages (2)
msg296400 - (view) Author: Damien George (Damien George) Date: 2017-06-20 04:36
The behaviour of the "async with" statement in CPython does not match the description of it in PEP492, nor the language documentation.  The implementation uses a try/except/finally block, while the PEP and documentation describe the behaviour using a try/except/else block.  The PEP and documentation should be updated to reflect the true intention of "async with".
msg296402 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2017-06-20 05:38
The specific issue is that early exits from an "async with" statement are actually defined the same way they for synchronous with statements: exiting early via return, break, or continue, is the same as reaching the end of the try block.

However, that's not what the documentation currently says: it describes "async with" in terms of try/except/else, which isn't correct.
History
Date User Action Args
2017-06-20 05:38:31ncoghlansetnosy: + ncoghlan, yselivanov
messages: + msg296402
2017-06-20 04:36:45Damien Georgesetmessages: + msg296400
2017-06-20 04:34:20Damien Georgecreate