diff options
| -rw-r--r-- | Misc/NEWS | 5 | ||||
| -rw-r--r-- | Python/ceval.c | 25 |
2 files changed, 25 insertions, 5 deletions
@@ -12,7 +12,10 @@ What's New in Python 3.0.1? Core and Builtins ----------------- -- Issue #4597: Fixed exception handling when the __exit__ function of a +- Issue #4597: Fixed several opcodes that weren't always propagating + exceptions. + +- Issue #4589: Fixed exception handling when the __exit__ function of a context manager returns a value that cannot be converted to a bool. - Issue #4533: File read operation was dreadfully slow due to a slowly diff --git a/Python/ceval.c b/Python/ceval.c index f58a55d7ba..c423c9f097 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1112,6 +1112,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: @@ -1728,6 +1729,7 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) if ((v = f->f_locals) == NULL) { PyErr_Format(PyExc_SystemError, "no locals when loading %R", w); + why = WHY_EXCEPTION; break; } if (PyDict_CheckExact(v)) { @@ -2279,7 +2281,10 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) if (x != NULL && opcode == MAKE_CLOSURE) { 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); } @@ -2303,7 +2308,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) Py_DECREF(w); } - err = PyFunction_SetAnnotations(x, v); + if (PyFunction_SetAnnotations(x, v) != 0) { + /* Can't happen unless + PyFunction_SetAnnotations changes. */ + why = WHY_EXCEPTION; + } Py_DECREF(v); Py_DECREF(u); } @@ -2320,7 +2329,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) w = POP(); PyTuple_SET_ITEM(v, posdefaults, 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); } if (x != NULL && kwdefaults > 0) { @@ -2338,7 +2351,11 @@ PyEval_EvalFrameEx(PyFrameObject *f, int throwflag) Py_DECREF(w); Py_DECREF(u); } - err = PyFunction_SetKwDefaults(x, v); + if (PyFunction_SetKwDefaults(x, v) != 0) { + /* Can't happen unless + PyFunction_SetKwDefaults changes. */ + why = WHY_EXCEPTION; + } Py_DECREF(v); } PUSH(x); |
