[issue43481] PyEval_EvalCode() namespace issue not observed in Python 2.7.

Chris Morton report at bugs.python.org
Sat Mar 20 11:29:56 EDT 2021


Chris Morton <chrisgmorton at yahoo.com> added the comment:

Hi Terry, The reason why your code does not reproduce the issue is because you first execute the code in a global context which then puts the definition of c in that context. Subsequent calling in the local context then works. If you remove the first exec call (no need for the Class lines either), you will now see the issue in 3.8.
This issue is reproducible for other containers such as lists and sets, instead of dictionary, in this case. Replacing range(len(c)) with range(4) also shows the same error. The error relates to the use of the indexing operator []. The same error is observed with other sequences such as:

c={1,2,3,4} 

or

c='1234'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43481>
_______________________________________


More information about the Python-bugs-list mailing list