Message357643
Sorry for the spamming, realised I misunderstood further.
The original behaviour isn't because the exec'd code can't create new local variables - it can - it's because of the documented behaviour of exec when it gets different dicts for globals and locals:
"If exec gets two separate objects as globals and locals, the code will be executed as if it were embedded in a class definition"
So the new scope made by the list comprehension can't access the enclosing scope in which the new variable was defined, because that's how scoping works in class definitions. |
|
Date |
User |
Action |
Args |
2019-11-29 15:36:37 | Chris Billington | set | recipients:
+ Chris Billington |
2019-11-29 15:36:37 | Chris Billington | set | messageid: <1575041797.51.0.388884498792.issue38937@roundup.psfhosted.org> |
2019-11-29 15:36:37 | Chris Billington | link | issue38937 messages |
2019-11-29 15:36:37 | Chris Billington | create | |
|