Mercurial > cpython-lru_cache-weakref
diff Python/ceval.c @ 50102:a6ddd94983ea 2.5
Backport issue 4597 to python 2.5.3: Fixed several opcodes that weren't always
propagating exceptions.
| author | Jeffrey Yasskin <jyasskin@gmail.com> |
|---|---|
| date | Wed, 10 Dec 2008 17:23:20 +0000 |
| parents | 694d04ed2b43 |
| children | 787b969d37f0 |
line wrap: on
line diff
--- a/Python/ceval.c Wed Dec 10 09:54:59 2008 +0000 +++ b/Python/ceval.c Wed Dec 10 17:23:20 2008 +0000 @@ -1025,6 +1025,7 @@ } Py_FatalError("invalid argument to DUP_TOPX" " (bytecode corruption?)"); + /* Never returns, so don't bother to set why. */ break; case UNARY_POSITIVE: @@ -1618,9 +1619,11 @@ 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) { Py_INCREF(w); @@ -1837,6 +1840,7 @@ PyErr_Format(PyExc_SystemError, "no locals when loading %s", PyObject_REPR(w)); + why = WHY_EXCEPTION; break; } if (PyDict_CheckExact(v)) { @@ -2381,7 +2385,10 @@ 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) { @@ -2395,7 +2402,11 @@ 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);
