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 7 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.

This comment has been minimized.

Copy link
@brettcannon

brettcannon Dec 16, 2019

Member

It's not important to match the grammar in this case as the docs are not kept in sync with the grammar rule names.

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 To 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). Before knowing about PEP 343 I did the same mistake (cf. https://stackoverflow.com/questions/59322585/what-is-the-exact-try-statement-equivalent-of-the-with-statement-in-python).

@maggyero maggyero requested a review from serhiy-storchaka Dec 14, 2019
maggyero added 2 commits Dec 15, 2019
@brettcannon brettcannon requested review from brettcannon and ncoghlan Dec 16, 2019
@brettcannon

This comment has been minimized.

Copy link
Member

brettcannon commented Dec 16, 2019

@maggyero your PR is failing CI.

Adding @ncoghlan as a reviewer since he probably is a good judge about the accuracy of the proposed clarification.

@maggyero maggyero force-pushed the maggyero:patch-13 branch from 5a59435 to 09f882a Dec 16, 2019
@maggyero maggyero force-pushed the maggyero:patch-13 branch from 09f882a to f7b273d Dec 16, 2019
@maggyero

This comment has been minimized.

Copy link
Contributor Author

maggyero commented Dec 16, 2019

@brettcannon Fixed, CI passed, thanks.

@brettcannon brettcannon requested review from 1st1 and asvetlov Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.