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 qpeter
Recipients qpeter
Date 2021-12-22.15:38:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640187480.74.0.946037624707.issue46153@roundup.psfhosted.org>
In-reply-to
Content
When both namespace arguments are given to exec, function definitions fail to capture closure. See below:
```
Python 3.8.6 (default, Oct  8 2020, 14:06:32) 
[Clang 12.0.0 (clang-1200.0.32.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> exec("a = 1\ndef f(): return a\nprint(f())")
1
>>> exec("a = 1\ndef f(): return a\nprint(f())", {})
1
>>> exec("a = 1\ndef f(): return a\nprint(f())", {}, {})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "<string>", line 2, in f
NameError: name 'a' is not defined
>>> 
```
History
Date User Action Args
2021-12-22 15:38:00qpetersetrecipients: + qpeter
2021-12-22 15:38:00qpetersetmessageid: <1640187480.74.0.946037624707.issue46153@roundup.psfhosted.org>
2021-12-22 15:38:00qpeterlinkissue46153 messages
2021-12-22 15:38:00qpetercreate