This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author dfugate
Recipients dfugate, georg.brandl
Date 2008-10-28.16:19:46
SpamBayes Score 2.0738707e-08
Marked as misclassified No
Message-id <1225210788.32.0.89272753959.issue4220@psf.upfronthosting.co.za>
In-reply-to
Content
#----------------------------------------------------------------------
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.
History
Date User Action Args
2008-10-28 16:19:48dfugatesetrecipients: + dfugate, georg.brandl
2008-10-28 16:19:48dfugatesetmessageid: <1225210788.32.0.89272753959.issue4220@psf.upfronthosting.co.za>
2008-10-28 16:19:47dfugatelinkissue4220 messages
2008-10-28 16:19:46dfugatecreate