bpo-39037: Look up __enter__ before __exit__ in the with statement documentation#17608
Merged
ncoghlan merged 8 commits intopython:masterfrom Dec 30, 2019
Merged
bpo-39037: Look up __enter__ before __exit__ in the with statement documentation#17608ncoghlan merged 8 commits intopython:masterfrom
ncoghlan merged 8 commits intopython:masterfrom
Conversation
The else clause should instead be a finally clause to also handle the case when there is a non-local goto statement (break, continue, return) in suite (cf. https://stackoverflow.com/questions/59322585/what-is-the-exact-try-statement-equivalent-of-the-with-statement-in-python).
Member
|
@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. |
Contributor
Author
|
@brettcannon Fixed, CI passed, thanks. |
ncoghlan
approved these changes
Dec 30, 2019
Contributor
|
Thanks @maggyero for the PR, and @ncoghlan for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
|
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 <[email protected]>
Contributor
Author
|
Thanks @serhiy-storchaka, @brettcannon and @ncoghlan for reviewing this PR! |
shihai1991
pushed a commit
to shihai1991/cpython
that referenced
this pull request
Jan 31, 2020
…ntation (pythonGH-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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will make these changes to the Compound statements chapter of the language documentation:
__exit__and__enter__methods in thewithstatement;trystatement of thewithstatement (since it is already given for theasync withstatement);elseclause with afinallyclause in the equivalenttrystatement of theasync withstatement, in order to also handle the case when there is a non-local goto statement (break,continue,return) in the suite (cf. https://stackoverflow.com/questions/59322585/what-is-the-exact-try-statement-equivalent-of-the-with-statement-in-python).https://bugs.python.org/issue39037