Issue 24637: locals dictionary in PyRun_String (original) (raw)
Issue24637
Created on 2015-07-15 13:23 by Matthew Keeter, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Files | |||
---|---|---|---|
File name | Uploaded | Description | Edit |
locals.patch | Matthew Keeter,2015-07-15 13:23 | review |
Messages (4) | ||
---|---|---|
msg246761 - (view) | Author: Matthew Keeter (Matthew Keeter) | Date: 2015-07-15 13:23 |
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 | ||
msg271830 - (view) | Author: Stéphane Wirtel (matrixise) * ![]() |
Date: 2016-08-02 16:32 |
the patch makes sense for me. | ||
msg272575 - (view) | Author: Roundup Robot (python-dev) ![]() |
Date: 2016-08-13 02:38 |
New changeset 0f2a09950ac8 by Berker Peksag in branch '3.5': Issue #24637: Document that locals can be any mapping object https://hg.python.org/cpython/rev/0f2a09950ac8 New changeset 61c4dbec2e2c by Berker Peksag in branch 'default': Issue #24637: Merge from 3.5 https://hg.python.org/cpython/rev/61c4dbec2e2c | ||
msg272576 - (view) | Author: Berker Peksag (berker.peksag) * ![]() |
Date: 2016-08-13 02:39 |
Thanks for the patch, Matthew! |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:18 | admin | set | github: 68825 |
2016-08-13 02:39:20 | berker.peksag | set | status: open -> closedresolution: fixedmessages: + stage: patch review -> resolved |
2016-08-13 02:38:17 | python-dev | set | nosy: + python-devmessages: + |
2016-08-02 16:32:54 | matrixise | set | nosy: + matrixisemessages: + |
2016-08-02 16:25:49 | berker.peksag | set | nosy: + berker.peksagstage: patch reviewversions: - Python 2.7, Python 3.2, Python 3.3, Python 3.4 |
2015-07-15 13:23:06 | Matthew Keeter | create |