diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-11-08 18:38:54 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-11-08 18:38:54 (GMT) |
commit | 2c98faada6f268d32c4031f7d09d9d5e6a2f46e3 (patch) | |
tree | b5555e4413d2df2147f15a12e563e83261564926 /Lib/test/test_syntax.py | |
parent | 942e4779b05dbf382e9b59a56a31ba311fa6e4d5 (diff) | |
download | cpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.zip cpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.tar.gz cpython-2c98faada6f268d32c4031f7d09d9d5e6a2f46e3.tar.bz2 |
check for assignment to __debug__ during AST generation
Also, give assignment to None a better error message
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index e978a6e..794564a 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -27,15 +27,13 @@ In ast.c, syntax errors are raised by calling ast_error(). Errors from set_context(): -TODO(jhylton): "assignment to None" is inconsistent with other messages - >>> obj.None = 1 Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[1]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[1]>, line 1) >>> None = 1 Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[2]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[2]>, line 1) It's a syntax error to assign to the empty tuple. Why isn't it an error to assign to the empty list? It will always raise some error at @@ -95,7 +93,7 @@ From compiler_complex_args(): >>> def f(None=1): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[14]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[14]>, line 1) From ast_for_arguments(): @@ -108,17 +106,17 @@ SyntaxError: non-default argument follows default argument (<doctest test.test_s >>> def f(x, None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[16]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[16]>, line 1) >>> def f(*None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[17]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[17]>, line 1) >>> def f(**None): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[18]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[18]>, line 1) From ast_for_funcdef(): @@ -126,7 +124,7 @@ From ast_for_funcdef(): >>> def None(x): ... pass Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[19]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[19]>, line 1) From ast_for_call(): @@ -231,7 +229,7 @@ Traceback (most recent call last): SyntaxError: augmented assignment to generator expression not possible (<doctest test.test_syntax[31]>, line 1) >>> None += 1 Traceback (most recent call last): -SyntaxError: assignment to None (<doctest test.test_syntax[32]>, line 1) +SyntaxError: cannot assign to None (<doctest test.test_syntax[32]>, line 1) >>> f() += 1 Traceback (most recent call last): SyntaxError: illegal expression for augmented assignment (<doctest test.test_syntax[33]>, line 1) |