From: Benjamin Peterson Date: Sat, 16 Oct 2010 03:45:45 +0000 (+0000) Subject: don't identify the toplevel namespace by name #9997 X-Git-Tag: v3.2a4~535 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=230b20684f6d10044d604bc88065692393037948;p=thirdparty%2FPython%2Fcpython.git don't identify the toplevel namespace by name #9997 --- diff --git a/Lib/test/test_scope.py b/Lib/test/test_scope.py index 0e5a8e92b42a..390e39f79c05 100644 --- a/Lib/test/test_scope.py +++ b/Lib/test/test_scope.py @@ -705,6 +705,14 @@ class ScopeTests(unittest.TestCase): 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) diff --git a/Misc/NEWS b/Misc/NEWS index 80aa50f23821..01a24427cc8a 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1? Core and Builtins ----------------- +- Issue #9997: Don't let the name "top" have special significance in scope + resolution. + - Issue #9862: Compensate for broken PIPE_BUF in AIX by hard coding its value as the default 512 when compiling on AIX. diff --git a/Python/symtable.c b/Python/symtable.c index f75b9c997f49..4a6c52335bb4 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -924,7 +924,7 @@ symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block, st->st_cur = ste_new(st, name, block, ast, lineno, col_offset); 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,