[pypy-svn] r78321 - in pypy/branch/fast-forward/pypy/interpreter/astcompiler: . test

afa at codespeak.net afa at codespeak.net
Tue Oct 26 22:42:32 CEST 2010


Author: afa
Date: Tue Oct 26 22:42:30 2010
New Revision: 78321

Modified:
   pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
   pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py
Log:
"import None as x" is not a SyntaxError
(None is not an assignment target here)


Modified: pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py	Tue Oct 26 22:42:30 2010
@@ -196,7 +196,8 @@
                 if len(import_name.children) == 1:
                     import_name = import_name.children[0]
                     continue
-                alias = self.alias_for_import_name(import_name.children[0])
+                alias = self.alias_for_import_name(import_name.children[0],
+                                                   store=False)
                 asname_node = import_name.children[2]
                 alias.asname = asname_node.value
                 self.check_forbidden_name(alias.asname, asname_node)

Modified: pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py	(original)
+++ pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py	Tue Oct 26 22:42:30 2010
@@ -795,6 +795,10 @@
                 input = template % (name,)
                 exc = py.test.raises(SyntaxError, self.get_ast, input).value
                 assert exc.msg == "cannot assign to %s" % (name,)
+        # This is ok.
+        self.get_ast("from None import x")
+        self.get_ast("from x import None as y")
+        self.get_ast("import None as x")
 
     def test_lambda(self):
         lam = self.get_first_expr("lambda x: expr")



More information about the Pypy-commit mailing list