Peter Eastman added the comment:

I don't believe that explanation is correct.  You can just as easily get the 
same problem without explicitly passing a map to exec().  For example:

def f():
    script = """
print(a)
print([a for i in range(5)])
    """
    a = 5
    exec(script)
    
f()

The documentation for exec() states, "In all cases, if the optional parts are 
omitted, the code is executed in the current scope."  Therefore the code above 
should be exactly equivalent to the following:

def f():
    a = 5
    print(a)
    print([a for i in range(5)])
    
f()

But the latter works and the former doesn't.  Contrary to the documentation, 
the code is clearly not being executed in the same scope.

----------
resolution: not a bug -> 
status: closed -> open

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue24800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to