This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Matthew Keeter
Recipients Matthew Keeter, docs@python
Date 2015-07-15.13:23:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1436966586.07.0.0153968460371.issue24637@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2015-07-15 13:23:06Matthew Keetersetrecipients: + Matthew Keeter, docs@python
2015-07-15 13:23:06Matthew Keetersetmessageid: <1436966586.07.0.0153968460371.issue24637@psf.upfronthosting.co.za>
2015-07-15 13:23:05Matthew Keeterlinkissue24637 messages
2015-07-15 13:23:05Matthew Keetercreate