[issue45707] Variable reassginment triggers incorrect behaviors of locals()

2021-11-03 Thread Josh Rosenberg
Josh Rosenberg added the comment: This is a documented feature of locals() (it's definitionally impossible to auto-vivify *real* locals, because real locals are statically assigned to specific indices in a fixed size array at function compile time, and the locals() function is returning a

[issue45707] Variable reassginment triggers incorrect behaviors of locals()

2021-11-03 Thread Dennis Sweeney
Dennis Sweeney added the comment: >From https://docs.python.org/3/library/functions.html#exec : "modifications to the default locals dictionary should not be attempted. Pass an explicit locals dictionary if you need to see effects of the code on locals after function exec() returns." There

[issue45707] Variable reassginment triggers incorrect behaviors of locals()

2021-11-03 Thread Xinmeng Xia
New submission from Xinmeng Xia : Normally after executing a piece of code in a function, locals() should contain the local variables and these variables can be reassigned next. In the following code, "attr" should be found in locals(). Actually, it can not be found in either locals() or