-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
PEP 572: TargetScopeError->SyntaxError, other SyntaxError adjustments #1140
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
PEP 572: TargetScopeError->SyntaxError, other SyntaxError adjustments #1140
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I am happy now! Not sure if @tim-one or @Rosuav want to chime in still?
CC: @emilyemorehouse
|
All good from my end! |
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