[issue36426] exec() issue when used inside function

2019-03-30 Thread Nick Coghlan
Nick Coghlan added the comment: This is not a bug - to enable function level optimisations, the compiler must be able to see all local variable names at compile time. In Python 2.x the exec statement implementation included special code to allow even function local variables to be rebound,

[issue36426] exec() issue when used inside function

2019-03-30 Thread Domen Jurkovič
Domen Jurkovič added the comment: Are there any workarounds - how can we use exec() and on-the-fly created variables? Also, why 'locals()['bar']' is seen by the interpretter, but not ony 'bar'? -- ___ Python tracker

[issue36426] exec() issue when used inside function

2019-03-29 Thread Terry J. Reedy
Terry J. Reedy added the comment: This is not a bug; the behavior is covered in the docs. I am surprised that this works in 2.7, as it has the same warning as 3.7: " locals() Update and return a dictionary representing the current local symbol table. Free variables are returned by

[issue36426] exec() issue when used inside function

2019-03-25 Thread Steve Dower
Steve Dower added the comment: This is currently by design, which means 3.8 is likely the only viable place it can change. It's also not Windows specific so I removed that component (people may remove themselves from nosy). But +Nick, since I know he has some interest in making locals()

[issue36426] exec() issue when used inside function

2019-03-25 Thread Emmanuel Arias
Emmanuel Arias added the comment: But I confirmed the behavior reported uhmm weird -- ___ Python tracker ___ ___

[issue36426] exec() issue when used inside function

2019-03-25 Thread Emmanuel Arias
Emmanuel Arias added the comment: I test on 3.5 and 3.8 running not in an func and I don't have the problem: Python 3.8.0a2+ (heads/bpo-36287:ba8f342623, Mar 25 2019, 21:57:16) [GCC 6.3.0 20170516] on linux Type "help", "copyright", "credits" or "license" for more information. >>> a = 'bar'

[issue36426] exec() issue when used inside function

2019-03-25 Thread Domen Jurkovič
Domen Jurkovič added the comment: Seems like I don't know how to write a code here. Anyway, issue created on stack overflow can be found on:

[issue36426] exec() issue when used inside function

2019-03-25 Thread Domen Jurkovič
New submission from Domen Jurkovič : I've reported a stack overflow question and no reasonable explation was offered. Here is what I've discovered: .. code-block:: python def func(): varName = 'bar' varValue = 42 localVarToEvaluate = varName + ' = varValue'