diff options
author | Nick Coghlan <ncoghlan@gmail.com> | 2019-08-25 13:45:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-25 13:45:40 (GMT) |
commit | 5dbe0f59b7a4f39c7c606b48056bc29e406ebf78 (patch) | |
tree | 9dd53ae948d0e49719d85d5e7814a6b1db61fdf3 /Objects/exceptions.c | |
parent | ce6a070414ed1e1374d1e6212bfbff61b6d5d755 (diff) | |
download | cpython-5dbe0f59b7a4f39c7c606b48056bc29e406ebf78.zip cpython-5dbe0f59b7a4f39c7c606b48056bc29e406ebf78.tar.gz cpython-5dbe0f59b7a4f39c7c606b48056bc29e406ebf78.tar.bz2 |
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)
Diffstat (limited to 'Objects/exceptions.c')
-rw-r--r-- | Objects/exceptions.c | 9 |
1 files changed, 0 insertions, 9 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c index ef9dd51..631f537 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -1522,13 +1522,6 @@ MiddlingExtendsException(PyExc_SyntaxError, IndentationError, SyntaxError, /* - * TargetScopeError extends SyntaxError - */ -MiddlingExtendsException(PyExc_SyntaxError, TargetScopeError, SyntaxError, - "Improper scope target."); - - -/* * TabError extends IndentationError */ MiddlingExtendsException(PyExc_IndentationError, TabError, SyntaxError, @@ -2539,7 +2532,6 @@ _PyExc_Init(void) PRE_INIT(AttributeError); PRE_INIT(SyntaxError); PRE_INIT(IndentationError); - PRE_INIT(TargetScopeError); PRE_INIT(TabError); PRE_INIT(LookupError); PRE_INIT(IndexError); @@ -2680,7 +2672,6 @@ _PyBuiltins_AddExceptions(PyObject *bltinmod) POST_INIT(AttributeError); POST_INIT(SyntaxError); POST_INIT(IndentationError); - POST_INIT(TargetScopeError); POST_INIT(TabError); POST_INIT(LookupError); POST_INIT(IndexError); |