[Python-bugs-list] [ python-Bugs-528274 ] Nested Scopes bug (Confirmed)

noreply@sourceforge.net noreply@sourceforge.net
Sun, 10 Mar 2002 15:38:07 -0800


Bugs item #528274, was opened at 2002-03-11 02:38
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=528274&group_id=5470

Category: None
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Alex A. Naanou (alex_nanou)
Assigned to: Nobody/Anonymous (nobody)
Summary: Nested Scopes bug (Confirmed)

Initial Comment:
Bug confirmed.

description:
names that a in a scope just above the scome of the 
nested block (function) do not appear that functions 
globals thus bracking SOME (!) of the code that uses 
them. in particular the eval function, and all code 
that explicitly searces the name in the globals.

code:
//see the attached file.

output:
- a NameError raised in function nested_1:
'NameError: global name 'a' is not defined'
- a NameError raised in function nested_2:
'NameError: name 'a' is not defined'

workarround:
explicitly pass the variable to the function as its 
default argument (as in nested_0).
NOTE: declaring the name global does not work (as 
shown in function nested_1).
//see the attached file for more details.

test results:
 there appears to be a gap between the globals and the 
locals of a nested function.

test systems:
WIN2K v.5.00.2195 SP2
- ActivePython 2.2 Alpha 2 build 1 (ActiveState) 
Python 2.2a2+ (#22, Sep  5 2001, 14:10:41) [MSC 32 bit 
(Intel)] on win32
- Python 2.2 (#1, Dec 31 2001, 15:21:18) [GCC 2.95.3-5 
(cygwin special)] on cygwin
FreeBSD 4.5 (LocalBuild)
Python2.2 //I do not remember the exact build.

                                       With Respect..
                                             Alex.

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=528274&group_id=5470