diff -r 57550e1f57d9 Python/errors.c --- a/Python/errors.c Tue Mar 24 14:01:32 2015 +0100 +++ b/Python/errors.c Tue Mar 24 15:39:47 2015 +0100 @@ -59,6 +59,8 @@ PyErr_SetObject(PyObject *exception, PyO PyObject *exc_value; PyObject *tb = NULL; + assert(!PyErr_Occurred()); + if (exception != NULL && !PyExceptionClass_Check(exception)) { PyErr_Format(PyExc_SystemError, @@ -75,10 +77,6 @@ PyErr_SetObject(PyObject *exception, PyO /* We must normalize the value right now */ PyObject *args, *fixed_value; - /* Issue #23571: PyEval_CallObject() must not be called with an - exception set */ - PyErr_Clear(); - if (value == NULL || value == Py_None) args = PyTuple_New(0); else if (PyTuple_Check(value)) { @@ -210,6 +208,7 @@ PyErr_GivenExceptionMatches(PyObject *er int PyErr_ExceptionMatches(PyObject *exc) { + assert(PyErr_Occurred()); return PyErr_GivenExceptionMatches(PyErr_Occurred(), exc); } @@ -778,9 +777,7 @@ PyErr_FormatV(PyObject *exception, const { PyObject* string; - /* Issue #23571: PyUnicode_FromFormatV() must not be called with an - exception set, it calls arbitrary Python code like PyObject_Repr() */ - PyErr_Clear(); + assert(!PyErr_Occurred()); string = PyUnicode_FromFormatV(format, vargs);