diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 00:19:37 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-10-29 00:19:37 (GMT) |
commit | 41bb43a71e1caa4e6993c6571544d415c9e178b9 (patch) | |
tree | 7c6dd0407d1aff5ba9c4e6b4789bee09f95b3fc2 /Python/bltinmodule.c | |
parent | 28c63f7ffb9f9cb59c524dc14ce66d34c0e83af6 (diff) | |
download | cpython-41bb43a71e1caa4e6993c6571544d415c9e178b9.zip cpython-41bb43a71e1caa4e6993c6571544d415c9e178b9.tar.gz cpython-41bb43a71e1caa4e6993c6571544d415c9e178b9.tar.bz2 |
Issue #18408: Add a new PyFrame_FastToLocalsWithError() function to handle
exceptions when merging fast locals into f_locals of a frame.
PyEval_GetLocals() now raises an exception and return NULL on failure.
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 4713874..b0be671 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -755,8 +755,11 @@ builtin_eval(PyObject *self, PyObject *args) } if (globals == Py_None) { globals = PyEval_GetGlobals(); - if (locals == Py_None) + if (locals == Py_None) { locals = PyEval_GetLocals(); + if (locals == NULL) + return NULL; + } } else if (locals == Py_None) locals = globals; @@ -820,6 +823,8 @@ builtin_exec(PyObject *self, PyObject *args) globals = PyEval_GetGlobals(); if (locals == Py_None) { locals = PyEval_GetLocals(); + if (locals == NULL) + return NULL; } if (!globals || !locals) { PyErr_SetString(PyExc_SystemError, @@ -1926,13 +1931,9 @@ builtin_vars(PyObject *self, PyObject *args) return NULL; if (v == NULL) { d = PyEval_GetLocals(); - if (d == NULL) { - if (!PyErr_Occurred()) - PyErr_SetString(PyExc_SystemError, - "vars(): no locals!?"); - } - else - Py_INCREF(d); + if (d == NULL) + return NULL; + Py_INCREF(d); } else { _Py_IDENTIFIER(__dict__); |