[Python-3000-checkins] r55666 - in python/branches/p3yk: Lib/test/test_syntax.py Python/ast.c
guido.van.rossum
python-3000-checkins at python.org
Wed May 30 05:02:01 CEST 2007
Author: guido.van.rossum
Date: Wed May 30 05:01:51 2007
New Revision: 55666
Modified:
python/branches/p3yk/Lib/test/test_syntax.py
python/branches/p3yk/Python/ast.c
Log:
Found another place that needs check for forbidden names.
Fixed test_syntax.py accordingly (it helped me find that one).
Modified: python/branches/p3yk/Lib/test/test_syntax.py
==============================================================================
--- python/branches/p3yk/Lib/test/test_syntax.py (original)
+++ python/branches/p3yk/Lib/test/test_syntax.py Wed May 30 05:01:51 2007
@@ -27,15 +27,13 @@
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: invalid syntax
>>> None = 1
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[2]>, line 1)
+SyntaxError: assignment to keyword (<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 @@
>>> def f(None=1):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[14]>, line 1)
+SyntaxError: invalid syntax
From ast_for_arguments():
@@ -108,17 +106,17 @@
>>> def f(x, None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[16]>, line 1)
+SyntaxError: invalid syntax
>>> def f(*None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[17]>, line 1)
+SyntaxError: invalid syntax
>>> def f(**None):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[18]>, line 1)
+SyntaxError: invalid syntax
From ast_for_funcdef():
@@ -126,7 +124,7 @@
>>> def None(x):
... pass
Traceback (most recent call last):
-SyntaxError: assignment to None (<doctest test.test_syntax[19]>, line 1)
+SyntaxError: invalid syntax
From ast_for_call():
@@ -231,7 +229,7 @@
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: assignment to keyword (<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)
Modified: python/branches/p3yk/Python/ast.c
==============================================================================
--- python/branches/p3yk/Python/ast.c (original)
+++ python/branches/p3yk/Python/ast.c Wed May 30 05:01:51 2007
@@ -2005,11 +2005,8 @@
"expression not possible");
return NULL;
case Name_kind: {
- const char *var_name = PyString_AS_STRING(expr1->v.Name.id);
- if (var_name[0] == 'N' && !strcmp(var_name, "None")) {
- ast_error(ch, "assignment to None");
+ if (forbidden_name(expr1, ch))
return NULL;
- }
break;
}
case Attribute_kind:
More information about the Python-3000-checkins
mailing list