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, steven.daprano
Date 2021-12-22.16:45:39
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1640191539.39.0.785381430041.issue46153@roundup.psfhosted.org>
In-reply-to
Content
The reason I am asking is that I am working on a debugger. The debugger stops on a frame which is inside a function. Let's say the locals is:
locals() == {"a": 1}
I now want to define a closure with exec. I might want to do something like:
exec("def f(): return a", globals(), locals())
But this doesn't work because of the issue I describe.I would expect f() to look for a in the locals().

Even more surprising is that if I use the second argument of exec, the code in the above comment starts to fail.
History
Date User Action Args
2021-12-22 16:45:39qpetersetrecipients: + qpeter, steven.daprano
2021-12-22 16:45:39qpetersetmessageid: <1640191539.39.0.785381430041.issue46153@roundup.psfhosted.org>
2021-12-22 16:45:39qpeterlinkissue46153 messages
2021-12-22 16:45:39qpetercreate