Author: Amaury Forgeot d'Arc <[email protected]>
Branch: py3.5
Changeset: r89530:a1c35f4c589a
Date: 2017-01-12 22:16 +0100
http://bitbucket.org/pypy/pypy/changeset/a1c35f4c589a/

Log:    This is how CPython reports all assignments to reserved names. (see
        test_syntax.py)

diff --git a/pypy/interpreter/astcompiler/astbuilder.py 
b/pypy/interpreter/astcompiler/astbuilder.py
--- a/pypy/interpreter/astcompiler/astbuilder.py
+++ b/pypy/interpreter/astcompiler/astbuilder.py
@@ -126,7 +126,7 @@
         try:
             misc.check_forbidden_name(name)
         except misc.ForbiddenNameAssignment as e:
-            self.error("cannot assign to %s" % (e.name,), node)
+            self.error("assignment to keyword", node)
 
     def new_identifier(self, name):
         return misc.new_identifier(self.space, name)
@@ -138,7 +138,7 @@
         except ast.UnacceptableExpressionContext as e:
             self.error_ast(e.msg, e.node)
         except misc.ForbiddenNameAssignment as e:
-            self.error_ast("cannot assign to %s" % (e.name,), e.node)
+            self.error_ast("assignment to keyword", e.node)
 
     def handle_del_stmt(self, del_node):
         targets = self.handle_exprlist(del_node.get_child(1), ast.Del)
diff --git a/pypy/interpreter/astcompiler/asthelpers.py 
b/pypy/interpreter/astcompiler/asthelpers.py
--- a/pypy/interpreter/astcompiler/asthelpers.py
+++ b/pypy/interpreter/astcompiler/asthelpers.py
@@ -182,5 +182,5 @@
 
 class __extend__(ast.NameConstant):
 
-    _description = "name constant"
+    _description = "keyword"
     constant = True
diff --git a/pypy/interpreter/astcompiler/test/test_astbuilder.py 
b/pypy/interpreter/astcompiler/test/test_astbuilder.py
--- a/pypy/interpreter/astcompiler/test/test_astbuilder.py
+++ b/pypy/interpreter/astcompiler/test/test_astbuilder.py
@@ -812,7 +812,7 @@
             for template in invalid:
                 input = template % (name,)
                 exc = py.test.raises(SyntaxError, self.get_ast, input).value
-                assert exc.msg == "cannot assign to %s" % (name,)
+                assert exc.msg == "assignment to keyword"
 
     def test_lambda(self):
         lam = self.get_first_expr("lambda x: expr")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to