There are several cases where Python statements are illegal when
used in conjunction with nested scopes that contain free
variables.
If a variable is referenced in an enclosing scope, it is illegal
to delete the name. An error will be reported at compile time.
If the wild card form of import -- "import *" -- is used in a
function and the function contains or is a nested block with free
variables, the compiler will raise a SyntaxError.
If exec is used in a function and the function contains or is a nested
block with free variables, the compiler will raise a SyntaxError
unless the exec explicitly specifies the local namespace for the exec.
(In other words, "exec obj" would be illegal, but "exec obj in ns"
would be legal.)
The builtin functions eval() and input() can not
access free variables unless the variables are also referenced by the
program text of the block that contains the call to eval()
or input().
Compatibility note: The compiler for Python 2.1 will issue
warnings for uses of nested functions that will behave differently
with nested scopes. The warnings will not be issued if nested scopes
are enabled via a future statement. If a name bound in a function
scope and the function contains a nested function scope that uses the
name, the compiler will issue a warning. The name resolution rules
will result in different bindings under Python 2.1 than under Python
2.2. The warning indicates that the program may not run correctly
with all versions of Python.