Local variables changed during exec() in Python 3.14 are not persistant
There seems to be a problem with changing a local variable within exec():
test = "test1"exec("test = 'test2'", {}, {"test": test})print(test) # <- erroneously returns test1
returns 'test1' - the change to 'test' during exec() has not persisted
However if passed inside a dict variable:
localDict = {"test": "test1"}exec("test = 'test2'", {}, localDict)test = localDict["test"]print(test) # <- correctly returns test2
It seems to work for some reason and returns 'test2'!
Is this a bug in exec() in Python 3.14?