[Python-Dev] Objecttype of 'locals' argument in PyEval_EvalCode
Daniel.Trstenjak at science-computing.de
Wed Nov 29 10:06:03 CET 2006
I would like to know the definition of the 'locals' object given to
PyEval_EvalCode. Has 'locals' to be a python dictionary or a subtype
of a python dictionary, or is it enough if the object implements the
The python implementation behaves different for the two following code
from modul import symbol
from modul import *
In the case of the first one, it's enough if the object 'locals' implements
the necessary protocols. The second one only works if the object 'locals'
is a type or subtype of dictionary.
The problem lies in Python-2.5/Python/ceval.c:
import_all_from(PyObject *locals, PyObject *v)
4046 value = PyObject_GetAttr(v, name);
4047 if (value == NULL)
4048 err = -1;
>>> 4050 err = PyDict_SetItem(locals, name, value);
Changing PyDict_SetItem in line 4050 with PyObject_SetAttr could fix it.
More information about the Python-Dev