Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 86715:4ef4578db38a
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.
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Tue, 29 Oct 2013 01:19:37 +0100 |
| parents | 3ce0102e4c1f |
| children | 28c04e954bb6 |
line wrap: on
line diff
--- a/Python/ceval.c Tue Oct 29 00:59:44 2013 +0100 +++ b/Python/ceval.c Tue Oct 29 01:19:37 2013 +0100 @@ -2472,7 +2472,9 @@ 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 @@ 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 @@ 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 *
