New submission from David Fugate <[EMAIL PROTECTED]>: #---------------------------------------------------------------------- VERSION AFFECTED: 2.5 and 2.6 BUILD TYPE: x86 FLAGS PASSED TO PYTHON.EXE: None OPERATING SYSTEM: 32-bit Windows Vista SP1
#---------------------------------------------------------------------- BRIEF DESCRIPTION: According to http://docs.python.org/dev/reference/executionmodel.html#interaction- with-dynamic-features, a free variable is a variable used from some local scope that is not defined there. The behavior of Python 2.5/2.6 is that it treats certain Python keywords and builtin types/functions used in nested scopes as free variables as well. This seems a little odd. Could the documentation be clarified to state: usage of certain Python keywords are considered to be free variables. I.e., a line simply containing "int" triggers the free variable behavior. Alternatively, usage of builtin types/functions could be allowed from nested functions with calls to "exec"… Thanks, Dave #---------------------------------------------------------------------- REPRODUCTION SNIPPET: def a(): def b(): x = long(3) #Replace me with "x = 3L" and this works int #This must be commented out exec "" emits the following: File "garbage.py", line 4 exec "" SyntaxError: unqualified exec is not allowed in function 'b' it is a nested function unless the "x = long(3)" and "int" lines are commented out. ---------- assignee: georg.brandl components: Documentation, Interpreter Core files: garbage.py messages: 75289 nosy: dfugate, georg.brandl severity: normal status: open title: Builtins treated as free variables? type: compile error versions: Python 2.5.3, Python 2.6 Added file: http://bugs.python.org/file11900/garbage.py _______________________________________ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4220> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com