Message246761
The C API docs for PyRun_StringFlags, PyEval_EvalCodeEx, and PyEval_EvalCode say that globals and locals both must be dictionaries. However, digging into the source [1] shows that locals can be any object implementing the mapping protocol. Furthermore, the Python docs for eval and exec (which end up taking the same path) match the implementation, saying that locals can be any mapping object (which has been true since 2.4).
The attached patch changes the C API docs to reflect the Python docs (and the actual implementation). No new tests are required, as test_general_eval [2] already checks that an arbitrary mapping object can be used as the locals variable in exec.
[1] https://github.com/python/cpython/blob/master/Objects/frameobject.c#L628-L629
[2] https://github.com/python/cpython/blob/master/Lib/test/test_builtin.py#L473 |
|
Date |
User |
Action |
Args |
2015-07-15 13:23:06 | Matthew Keeter | set | recipients:
+ Matthew Keeter, docs@python |
2015-07-15 13:23:06 | Matthew Keeter | set | messageid: <1436966586.07.0.0153968460371.issue24637@psf.upfronthosting.co.za> |
2015-07-15 13:23:05 | Matthew Keeter | link | issue24637 messages |
2015-07-15 13:23:05 | Matthew Keeter | create | |
|