Skip to content

Commit e963349

Browse files
committed
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 ........
1 parent c404afd commit e963349

3 files changed

Lines changed: 12 additions & 1 deletion

File tree

Lib/test/test_scope.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,14 @@ def h():
693693
h = g()
694694
self.assertEqual(h(), 3)
695695

696+
def testTopIsNotSignificant(self):
697+
# See #9997.
698+
def top(a):
699+
pass
700+
def b():
701+
global a
702+
703+
696704

697705
def test_main():
698706
run_unittest(ScopeTests)

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ Core and Builtins
1313
- Issue #10006: type.__abstractmethods__ now raises an AttributeError. As a
1414
result metaclasses can now be ABCs (see #9533).
1515

16+
- Issue #9997: Don't let the name "top" have special significance in scope
17+
resolution.
18+
1619
- Issue #9930: Remove bogus subtype check that was causing (e.g.)
1720
float.__rdiv__(2.0, 3) to return NotImplemented instead of the
1821
expected 1.5.

Python/symtable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,7 +923,7 @@ symtable_enter_block(struct symtable *st, identifier name, _Py_block_ty block,
923923
st->st_cur = ste_new(st, name, block, ast, lineno);
924924
if (st->st_cur == NULL)
925925
return 0;
926-
if (name == GET_IDENTIFIER(top))
926+
if (block == ModuleBlock)
927927
st->st_global = st->st_cur->ste_symbols;
928928
if (prev) {
929929
if (PyList_Append(prev->ste_children,

0 commit comments

Comments
 (0)