mirror of
https://github.com/python/cpython.git
synced 2025-08-01 15:43:13 +00:00
[3.8] bpo-37757: Disallow PEP 572 cases that expose implementation details (GH-15491)
- 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 5dbe0f59b7
)
This commit is contained in:
parent
970548c00b
commit
6ca030765d
10 changed files with 191 additions and 76 deletions
|
@ -97,7 +97,6 @@ PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
|
|||
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IndentationError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TabError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TargetScopeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemExit;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue