mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
don't identify the toplevel namespace by name #9997
This commit is contained in:
parent
294a9fcba6
commit
230b20684f
3 changed files with 12 additions and 1 deletions
|
@ -705,6 +705,14 @@ class ScopeTests(unittest.TestCase):
|
||||||
h = g()
|
h = g()
|
||||||
self.assertEqual(h(), 3)
|
self.assertEqual(h(), 3)
|
||||||
|
|
||||||
|
def testTopIsNotSignificant(self):
|
||||||
|
# See #9997.
|
||||||
|
def top(a):
|
||||||
|
pass
|
||||||
|
def b():
|
||||||
|
global a
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
run_unittest(ScopeTests)
|
run_unittest(ScopeTests)
|
||||||
|
|
|
@ -10,6 +10,9 @@ What's New in Python 3.2 Beta 1?
|
||||||
Core and Builtins
|
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
|
- Issue #9862: Compensate for broken PIPE_BUF in AIX by hard coding
|
||||||
its value as the default 512 when compiling on AIX.
|
its value as the default 512 when compiling on AIX.
|
||||||
|
|
||||||
|
|
|
@ -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);
|
st->st_cur = ste_new(st, name, block, ast, lineno, col_offset);
|
||||||
if (st->st_cur == NULL)
|
if (st->st_cur == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (name == GET_IDENTIFIER(top))
|
if (block == ModuleBlock)
|
||||||
st->st_global = st->st_cur->ste_symbols;
|
st->st_global = st->st_cur->ste_symbols;
|
||||||
if (prev) {
|
if (prev) {
|
||||||
if (PyList_Append(prev->ste_children,
|
if (PyList_Append(prev->ste_children,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue