]> granicus.if.org Git - python/commit
bpo-37757: Disallow PEP 572 cases that expose implementation details (GH-15131)
authorNick Coghlan <ncoghlan@gmail.com>
Sun, 25 Aug 2019 13:45:40 +0000 (23:45 +1000)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2019 13:45:40 +0000 (23:45 +1000)
commit5dbe0f59b7a4f39c7c606b48056bc29e406ebf78
tree9dd53ae948d0e49719d85d5e7814a6b1db61fdf3
parentce6a070414ed1e1374d1e6212bfbff61b6d5d755
bpo-37757: Disallow PEP 572 cases that expose implementation details (GH-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)
Doc/c-api/exceptions.rst
Include/pyerrors.h
Include/symtable.h
Lib/_compat_pickle.py
Lib/test/exception_hierarchy.txt
Lib/test/test_named_expressions.py
Misc/NEWS.d/next/Core and Builtins/2019-08-05-14-22-59.bpo-37757.lRv5HX.rst [new file with mode: 0644]
Objects/exceptions.c
PC/python3.def
Python/symtable.c