[Python-checkins] r85563 - in python/branches/release31-maint: Lib/test/test_scope.py Misc/NEWS Python/symtable.c

benjamin.peterson python-checkins at python.org
Sat Oct 16 05:49:22 CEST 2010


Author: benjamin.peterson
Date: Sat Oct 16 05:49:22 2010
New Revision: 85563

Log:
Merged revisions 85562 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85562 | benjamin.peterson | 2010-10-15 22:45:45 -0500 (Fri, 15 Oct 2010) | 1 line
  
  don't identify the toplevel namespace by name #9997
........


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/test/test_scope.py
   python/branches/release31-maint/Misc/NEWS
   python/branches/release31-maint/Python/symtable.c

Modified: python/branches/release31-maint/Lib/test/test_scope.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_scope.py	(original)
+++ python/branches/release31-maint/Lib/test/test_scope.py	Sat Oct 16 05:49:22 2010
@@ -693,6 +693,14 @@
         h = g()
         self.assertEqual(h(), 3)
 
+    def testTopIsNotSignificant(self):
+        # See #9997.
+        def top(a):
+            pass
+        def b():
+            global a
+
+
 
 def test_main():
     run_unittest(ScopeTests)

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Sat Oct 16 05:49:22 2010
@@ -13,6 +13,9 @@
 - Issue #10006: type.__abstractmethods__ now raises an AttributeError.  As a
   result metaclasses can now be ABCs (see #9533).
 
+- Issue #9997: Don't let the name "top" have special significance in scope
+  resolution.
+
 - Issue #9930: Remove bogus subtype check that was causing (e.g.)
   float.__rdiv__(2.0, 3) to return NotImplemented instead of the
   expected 1.5.

Modified: python/branches/release31-maint/Python/symtable.c
==============================================================================
--- python/branches/release31-maint/Python/symtable.c	(original)
+++ python/branches/release31-maint/Python/symtable.c	Sat Oct 16 05:49:22 2010
@@ -923,7 +923,7 @@
     st->st_cur = ste_new(st, name, block, ast, lineno);
     if (st->st_cur == NULL)
         return 0;
-    if (name == GET_IDENTIFIER(top))
+    if (block == ModuleBlock)
         st->st_global = st->st_cur->ste_symbols;
     if (prev) {
         if (PyList_Append(prev->ste_children,


More information about the Python-checkins mailing list