Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-39037: Fix the trial order of the __exit__ and __enter__ methods in the with statement documentation #17608

Open
wants to merge 6 commits into
base: master
from

Conversation

@maggyero
Copy link
Contributor

maggyero commented Dec 14, 2019

This PR will make these changes to the Compound statements chapter of the language documentation:

https://bugs.python.org/issue39037

@maggyero maggyero changed the title bpo-39037: Fix wrong trial order of __exit__ and __enter__ in the with statement bpo-39037: Fix the trial order of the __exit__ and __enter__ methods in the with statement documentation Dec 14, 2019
Doc/reference/compound_stmts.rst Outdated Show resolved Hide resolved
Doc/reference/compound_stmts.rst Outdated Show resolved Hide resolved
@@ -811,23 +834,26 @@ able to suspend execution in its *enter* and *exit* methods.

The following code::

async with EXPR as VAR:
BLOCK
async with expression as target:

This comment has been minimized.

Copy link
@serhiy-storchaka

serhiy-storchaka Dec 14, 2019

Member

What is the purpose of this change?

This comment has been minimized.

Copy link
@maggyero

maggyero Dec 14, 2019

Author Contributor

@serhiy-storchaka To use the same terms as in the grammar.

raise
else:
await aexit(mgr, None, None, None)
finally:

This comment has been minimized.

Copy link
@serhiy-storchaka

serhiy-storchaka Dec 14, 2019

Member

Why replace else with finally?

This comment has been minimized.

Copy link
@maggyero

maggyero Dec 14, 2019

Author Contributor

@serhiy-storchaka In order to also handle the case when there is a non-local goto statement (break, continue, return) in the suite (cf. https://www.python.org/dev/peps/pep-0343/#specification-the-with-statement).

This comment has been minimized.

@maggyero maggyero requested a review from serhiy-storchaka Dec 14, 2019
maggyero added 2 commits Dec 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.