Any explanation of exec's behavior?
<p>Looking for good explanation of why this code raises <code>SyntaxError</code>. </p>

<pre><code>def echo(x):
    return x

def foo(s):
    d = {}
    exec(s, {}, d)
    return dict((x,y) for x,y in d.items())

def bar(s):
    d = {}
    exec(s, {}, d)
    return dict((x, echo(y)) for x,y in d.items()) # comment this to compile

s = 'a=1'
foo(s)
</code></pre>

<hr>

<pre><code>  File "test.py", line 11
    exec(s, {}, d)
SyntaxError: unqualified exec is not allowed in function 'bar' it contains a
             nested function with free variables
</code></pre>
