Skip to content

Conversation

@ncoghlan
Copy link
Contributor

@ncoghlan ncoghlan commented Aug 25, 2019

  • drop TargetScopeError in favour of raising SyntaxError directly
    as per the updated PEP 572
  • comprehension iteration variables are explicitly local, but
    named expression targets in comprehensions are nonlocal or
    global. Raise SyntaxError as specified in PEP 572
  • named expression targets in the outermost iterable of a
    comprehension have an ambiguous target scope. Avoid resolving
    that question now by raising SyntaxError. PEP 572
    originally required this only for cases where the bound name
    conflicts with the iteration variable in the comprehension,
    but CPython can't easily restrict the exception to that case
    (as it doesn't know the target variable names when visiting
    the outermost iterator expression)

(cherry picked from commit 5dbe0f5)

https://bugs.python.org/issue37757

…ythonGH-15131)

- drop TargetScopeError in favour of raising SyntaxError directly
  as per the updated PEP 572
- comprehension iteration variables are explicitly local, but
  named expression targets in comprehensions are nonlocal or
  global. Raise SyntaxError as specified in PEP 572
- named expression targets in the outermost iterable of a
  comprehension have an ambiguous target scope. Avoid resolving
  that question now by raising SyntaxError. PEP 572
  originally required this only for cases where the bound name
  conflicts with the iteration variable in the comprehension,
  but CPython can't easily restrict the exception to that case
  (as it doesn't know the target variable names when visiting
  the outermost iterator expression)

(cherry picked from commit 5dbe0f5)
@ncoghlan ncoghlan requested a review from a team as a code owner August 25, 2019 14:10
@ncoghlan ncoghlan changed the title bpo-37757: Disallow PEP 572 cases that expose implementation details [3.8] bpo-37757: Disallow PEP 572 cases that expose implementation details Aug 25, 2019
@ncoghlan ncoghlan merged commit 6ca0307 into python:3.8 Aug 25, 2019
@ncoghlan ncoghlan deleted the backport-5dbe0f5-3.8 branch August 25, 2019 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants