PEP 572: TargetScopeError->SyntaxError, other SyntaxError adjustments#1140
Merged
ncoghlan merged 5 commits intopython:masterfrom Aug 14, 2019
Merged
Conversation
- clarify rationale for the extra TargetScopeError cases (we don't want current CPython implementation details to implicitly leak into the "do what CPython does" de facto language specification) - broaden one of the error cases to handle the fact that CPython's symbol table analysis for a comprehension involves two different scopes and hence makes it difficult to detect when the target of a named expression in the iterable expression gets re-used as an iteration variable in the comprehension
gvanrossum
reviewed
Aug 5, 2019
Member
gvanrossum
left a comment
There was a problem hiding this comment.
Thanks for doing this! I have some nits.
Also, I wonder if we could smuggle a reference to "walrus operator" into the abstract, to aid search engines?
- drop TargetScopeError from the PEP in favour of SyntaxError - use the same marker for invalid constructs as the rest of the PEP - clarify that the ban on named expressions in comprehension iterable expressions is consistent (rather than only being on the first one) - provide a bit more detail on the CPython constraint that keeps us from implementing the "only complain on name conflicts" rule for iterable expressions - add a new note on naming that covers both the informal name and the internal name in the reference implementation
gvanrossum
approved these changes
Aug 10, 2019
Member
gvanrossum
left a comment
There was a problem hiding this comment.
OK, I am happy now! Not sure if @tim-one or @Rosuav want to chime in still?
CC: @emilyemorehouse
Contributor
|
All good from my end! |
warsaw
approved these changes
Aug 13, 2019
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.
TargetScopeErrorto a plainSyntaxErroras per referenced python-dev discussion
want current CPython implementation details to implicitly leak into
the "do what CPython does" de facto language specification)
symbol table analysis for a comprehension involves two different
scopes and hence makes it difficult to detect when the target of
a named expression in the iterable expression gets re-used as an
iteration variable in the comprehension