Message409042
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. |
|
Date |
User |
Action |
Args |
2021-12-22 16:45:39 | qpeter | set | recipients:
+ qpeter, steven.daprano |
2021-12-22 16:45:39 | qpeter | set | messageid: <1640191539.39.0.785381430041.issue46153@roundup.psfhosted.org> |
2021-12-22 16:45:39 | qpeter | link | issue46153 messages |
2021-12-22 16:45:39 | qpeter | create | |
|