Skip to content

Commit a5a5728

Browse files
committed
remove error checks already done in set_context()
1 parent 8ea4ded commit a5a5728

File tree

4 files changed

+5
-30
lines changed

4 files changed

+5
-30
lines changed

Lib/test/test_generators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,7 @@ def printsolution(self, x):
15881588
Traceback (most recent call last):
15891589
...
15901590
File "<doctest test.test_generators.__test__.coroutine[25]>", line 1
1591-
SyntaxError: augmented assignment to yield expression not possible
1591+
SyntaxError: can't assign to yield expression
15921592
15931593
15941594
Now check some throw() conditions:

Lib/test/test_genexps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
Traceback (most recent call last):
145145
...
146146
File "<doctest test.test_genexps.__test__.doctests[41]>", line 1
147-
SyntaxError: augmented assignment to generator expression not possible
147+
SyntaxError: can't assign to generator expression
148148
149149
150150
########### Tests borrowed from or inspired by test_generators.py ############

Lib/test/test_syntax.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,20 +248,20 @@
248248
SyntaxError: keyword can't be an expression
249249
250250
251-
From ast_for_expr_stmt():
251+
More set_context():
252252
253253
>>> (x for x in x) += 1
254254
Traceback (most recent call last):
255255
File "<doctest test.test_syntax[31]>", line 1
256-
SyntaxError: augmented assignment to generator expression not possible
256+
SyntaxError: can't assign to generator expression
257257
>>> None += 1
258258
Traceback (most recent call last):
259259
File "<doctest test.test_syntax[32]>", line 1
260260
SyntaxError: cannot assign to None
261261
>>> f() += 1
262262
Traceback (most recent call last):
263263
File "<doctest test.test_syntax[33]>", line 1
264-
SyntaxError: illegal expression for augmented assignment
264+
SyntaxError: can't assign to function call
265265
266266
267267
Test continue in finally in weird combinations.

Python/ast.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,31 +2088,6 @@ ast_for_expr_stmt(struct compiling *c, const node *n)
20882088
expr1 = ast_for_testlist(c, ch);
20892089
if (!expr1)
20902090
return NULL;
2091-
/* TODO(nas): Remove duplicated error checks (set_context does it) */
2092-
switch (expr1->kind) {
2093-
case GeneratorExp_kind:
2094-
ast_error(ch, "augmented assignment to generator "
2095-
"expression not possible");
2096-
return NULL;
2097-
case Yield_kind:
2098-
ast_error(ch, "augmented assignment to yield "
2099-
"expression not possible");
2100-
return NULL;
2101-
case Name_kind: {
2102-
const char *var_name = PyBytes_AS_STRING(expr1->v.Name.id);
2103-
if ((var_name[0] == 'N' || var_name[0] == 'T' || var_name[0] == 'F') &&
2104-
!forbidden_check(c, ch, var_name))
2105-
return NULL;
2106-
break;
2107-
}
2108-
case Attribute_kind:
2109-
case Subscript_kind:
2110-
break;
2111-
default:
2112-
ast_error(ch, "illegal expression for augmented "
2113-
"assignment");
2114-
return NULL;
2115-
}
21162091
if(!set_context(c, expr1, Store, ch))
21172092
return NULL;
21182093

0 commit comments

Comments
 (0)