mirror of https://github.com/python/cpython
remove error checks already done in set_context()
This commit is contained in:
parent
8ea4ded9a6
commit
a5a5728cf0
|
@ -1588,7 +1588,7 @@ SyntaxError: can't assign to yield expression
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
File "<doctest test.test_generators.__test__.coroutine[25]>", line 1
|
File "<doctest test.test_generators.__test__.coroutine[25]>", line 1
|
||||||
SyntaxError: augmented assignment to yield expression not possible
|
SyntaxError: can't assign to yield expression
|
||||||
|
|
||||||
|
|
||||||
Now check some throw() conditions:
|
Now check some throw() conditions:
|
||||||
|
|
|
@ -144,7 +144,7 @@ Verify that syntax error's are raised for genexps used as lvalues
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
File "<doctest test.test_genexps.__test__.doctests[41]>", line 1
|
File "<doctest test.test_genexps.__test__.doctests[41]>", line 1
|
||||||
SyntaxError: augmented assignment to generator expression not possible
|
SyntaxError: can't assign to generator expression
|
||||||
|
|
||||||
|
|
||||||
########### Tests borrowed from or inspired by test_generators.py ############
|
########### Tests borrowed from or inspired by test_generators.py ############
|
||||||
|
|
|
@ -248,12 +248,12 @@ Traceback (most recent call last):
|
||||||
SyntaxError: keyword can't be an expression
|
SyntaxError: keyword can't be an expression
|
||||||
|
|
||||||
|
|
||||||
From ast_for_expr_stmt():
|
More set_context():
|
||||||
|
|
||||||
>>> (x for x in x) += 1
|
>>> (x for x in x) += 1
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<doctest test.test_syntax[31]>", line 1
|
File "<doctest test.test_syntax[31]>", line 1
|
||||||
SyntaxError: augmented assignment to generator expression not possible
|
SyntaxError: can't assign to generator expression
|
||||||
>>> None += 1
|
>>> None += 1
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<doctest test.test_syntax[32]>", line 1
|
File "<doctest test.test_syntax[32]>", line 1
|
||||||
|
@ -261,7 +261,7 @@ SyntaxError: cannot assign to None
|
||||||
>>> f() += 1
|
>>> f() += 1
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
File "<doctest test.test_syntax[33]>", line 1
|
File "<doctest test.test_syntax[33]>", line 1
|
||||||
SyntaxError: illegal expression for augmented assignment
|
SyntaxError: can't assign to function call
|
||||||
|
|
||||||
|
|
||||||
Test continue in finally in weird combinations.
|
Test continue in finally in weird combinations.
|
||||||
|
|
25
Python/ast.c
25
Python/ast.c
|
@ -2088,31 +2088,6 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
|
||||||
expr1 = ast_for_testlist(c, ch);
|
expr1 = ast_for_testlist(c, ch);
|
||||||
if (!expr1)
|
if (!expr1)
|
||||||
return NULL;
|
return NULL;
|
||||||
/* TODO(nas): Remove duplicated error checks (set_context does it) */
|
|
||||||
switch (expr1->kind) {
|
|
||||||
case GeneratorExp_kind:
|
|
||||||
ast_error(ch, "augmented assignment to generator "
|
|
||||||
"expression not possible");
|
|
||||||
return NULL;
|
|
||||||
case Yield_kind:
|
|
||||||
ast_error(ch, "augmented assignment to yield "
|
|
||||||
"expression not possible");
|
|
||||||
return NULL;
|
|
||||||
case Name_kind: {
|
|
||||||
const char *var_name = PyBytes_AS_STRING(expr1->v.Name.id);
|
|
||||||
if ((var_name[0] == 'N' || var_name[0] == 'T' || var_name[0] == 'F') &&
|
|
||||||
!forbidden_check(c, ch, var_name))
|
|
||||||
return NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Attribute_kind:
|
|
||||||
case Subscript_kind:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ast_error(ch, "illegal expression for augmented "
|
|
||||||
"assignment");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if(!set_context(c, expr1, Store, ch))
|
if(!set_context(c, expr1, Store, ch))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue