Quentin Peter <qpe...@bluewin.ch> added the comment:

Fails for functions as well:
```
In [4]: exec(compile('print(my_var)\ndef a():\n print(my_var)\na()', '<stdin>', 
'exec'), globals(), {"my_var": 0})
0
Traceback (most recent call last):

File "<ipython-input-4-f091e49f2781>", line 1, in <module>
exec(compile('print(my_var)\ndef a():\n print(my_var)\na()', '<stdin>', 
'exec'), globals(), {"my_var": 0})

File "<stdin>", line 4, in <module>

 File "<stdin>", line 3, in a

NameError: name 'my_var' is not defined
```

----------
title: exec fails to take locals into account when running list comprehensions 
-> exec fails to take locals into account when running list comprehensions or 
functions

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

Reply via email to