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

Merged
merged 8 commits into from Dec 30, 2019

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.

This comment has been minimized.

Copy link
@ncoghlan

ncoghlan Dec 18, 2019

Contributor

Right, we deliberately use ALL_CAPS in these semantic expansions to distinguish the placeholders from keywords and hidden variables.

This comment has been minimized.

Copy link
@maggyero

maggyero Dec 18, 2019

Author Contributor

@ncoghlan All right, updated.

Doc/reference/compound_stmts.rst Show resolved Hide resolved
@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
@ncoghlan ncoghlan added the skip news label Dec 30, 2019
@ncoghlan ncoghlan merged commit 226e6e7 into python:master Dec 30, 2019
5 checks passed
5 checks passed
Docs
Details
Azure Pipelines PR #20191218.4 succeeded
Details
bedevere/issue-number Issue number 39037 found
Details
bedevere/news "skip news" label found
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Dec 30, 2019

Thanks @maggyero for the PR, and @ncoghlan for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖

@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Dec 30, 2019

GH-17749 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Dec 30, 2019
…ntation (GH-17608)

* __enter__ is now looked up before __exit__ to give a more intuitive error message
* add pseudo-code equivalent for the with statement
* fix pseudo-code for the async with statement to use a finally clause
* use SUITE rather than BLOCK for consistency with the language grammar

Patch by Géry Ogam.
(cherry picked from commit 226e6e7)

Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
@maggyero maggyero deleted the maggyero:patch-13 branch Dec 30, 2019
@maggyero

This comment has been minimized.

Copy link
Contributor Author

maggyero commented Dec 30, 2019

Thanks @serhiy-storchaka, @brettcannon and @ncoghlan for reviewing this PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.