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/ceval.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/ceval.c')
-rw-r--r-- | Python/ceval.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 2d52862..5f49615 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -2472,7 +2472,9 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) TARGET(IMPORT_STAR) { PyObject *from = POP(), *locals; int err; - PyFrame_FastToLocals(f); + if (PyFrame_FastToLocalsWithError(f) < 0) + goto error; + locals = f->f_locals; if (locals == NULL) { PyErr_SetString(PyExc_SystemError, @@ -4005,9 +4007,15 @@ PyObject * PyEval_GetLocals(void) { PyFrameObject *current_frame = PyEval_GetFrame(); - if (current_frame == NULL) + if (current_frame == NULL) { + PyErr_SetString(PyExc_SystemError, "frame does not exist"); return NULL; - PyFrame_FastToLocals(current_frame); + } + + if (PyFrame_FastToLocalsWithError(current_frame) < 0) + return NULL; + + assert(current_frame->f_locals != NULL); return current_frame->f_locals; } @@ -4017,8 +4025,9 @@ PyEval_GetGlobals(void) PyFrameObject *current_frame = PyEval_GetFrame(); if (current_frame == NULL) return NULL; - else - return current_frame->f_globals; + + assert(current_frame->f_globals != NULL); + return current_frame->f_globals; } PyFrameObject * |