diff options
author | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-12-08 18:55:24 (GMT) |
---|---|---|
committer | Jeffrey Yasskin <jyasskin@gmail.com> | 2008-12-08 18:55:24 (GMT) |
commit | 2d873bd68b400e056e77790ca72cc7a7d8a5d07c (patch) | |
tree | e344b96c7be4aa694f49f3ffb510c32edb49f038 /Python | |
parent | b5120ceae2b323c0493f26136e820e8f5a5a5c45 (diff) | |
download | cpython-2d873bd68b400e056e77790ca72cc7a7d8a5d07c.zip cpython-2d873bd68b400e056e77790ca72cc7a7d8a5d07c.tar.gz cpython-2d873bd68b400e056e77790ca72cc7a7d8a5d07c.tar.bz2 |
Issue 4597: Fix several cases in EvalFrameEx where an exception could be
"raised" without setting x, err, or why to let the eval loop know.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index cdcf9f6..0a1d86a 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1049,6 +1049,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) } Py_FatalError("invalid argument to DUP_TOPX" " (bytecode corruption?)"); + /* Never returns, so don't bother to set why. */ break; case UNARY_POSITIVE: @@ -1642,9 +1643,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) case PRINT_NEWLINE: if (stream == NULL || stream == Py_None) { w = PySys_GetObject("stdout"); - if (w == NULL) + if (w == NULL) { PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + why = WHY_EXCEPTION; + } } if (w != NULL) { /* w.write() may replace sys.stdout, so we @@ -1870,6 +1873,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) PyErr_Format(PyExc_SystemError, "no locals when loading %s", PyObject_REPR(w)); + why = WHY_EXCEPTION; break; } if (PyDict_CheckExact(v)) { @@ -2459,7 +2463,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) Py_DECREF(v); if (x != NULL) { v = POP(); - err = PyFunction_SetClosure(x, v); + if (PyFunction_SetClosure(x, v) != 0) { + /* Can't happen unless bytecode is corrupt. */ + why = WHY_EXCEPTION; + } Py_DECREF(v); } if (x != NULL && oparg > 0) { @@ -2473,7 +2480,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) w = POP(); PyTuple_SET_ITEM(v, oparg, w); } - err = PyFunction_SetDefaults(x, v); + if (PyFunction_SetDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetDefaults changes. */ + why = WHY_EXCEPTION; + } Py_DECREF(v); } PUSH(x); |