[Python-checkins] r73409 - in python/trunk: Lib/test/test_compile.py Python/ast.c

benjamin.peterson python-checkins at python.org
Sat Jun 13 15:06:21 CEST 2009


Author: benjamin.peterson
Date: Sat Jun 13 15:06:21 2009
New Revision: 73409
Log:
allow importing from a module named None if it has an 'as' clause
Modified:
 python/trunk/Lib/test/test_compile.py
 python/trunk/Python/ast.c
Modified: python/trunk/Lib/test/test_compile.py
==============================================================================
--- python/trunk/Lib/test/test_compile.py	(original)
+++ python/trunk/Lib/test/test_compile.py	Sat Jun 13 15:06:21 2009
@@ -281,6 +281,8 @@
 self.assertRaises(SyntaxError, compile, stmt, 'tmp', 'exec')
 # This is ok.
 compile("from None import x", "tmp", "exec")
+ compile("from x import None as y", "tmp", "exec")
+ compile("import None as x", "tmp", "exec")
 
 def test_import(self):
 succeed = [
Modified: python/trunk/Python/ast.c
==============================================================================
--- python/trunk/Python/ast.c	(original)
+++ python/trunk/Python/ast.c	Sat Jun 13 15:06:21 2009
@@ -2316,8 +2316,10 @@
 if (!str)
 return NULL;
 }
- if (!forbidden_check(c, name_node, STR(name_node)))
- return NULL;
+ else {
+ if (!forbidden_check(c, name_node, STR(name_node)))
+ return NULL;
+ }
 name = NEW_IDENTIFIER(name_node);
 if (!name)
 return NULL;
@@ -2330,11 +2332,11 @@
 }
 else {
 node *asname_node = CHILD(n, 2);
- alias_ty a = alias_for_import_name(c, CHILD(n, 0), store);
+ alias_ty a = alias_for_import_name(c, CHILD(n, 0), 0);
 if (!a)
 return NULL;
 assert(!a->asname);
- if (store && !forbidden_check(c, asname_node, STR(asname_node)))
+ if (!forbidden_check(c, asname_node, STR(asname_node)))
 return NULL;
 a->asname = NEW_IDENTIFIER(asname_node);
 if (!a->asname)


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /