diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-03-24 11:41:23 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-03-24 11:41:23 (GMT) |
commit | de821befd4a924adb50458163a14dfe6ea9ed448 (patch) | |
tree | 85c045877ba89bb3b83a047e46a27977326b641a /Python/errors.c | |
parent | 91afbb60885d5904dc6cb4d063ae33454507bf71 (diff) | |
download | cpython-de821befd4a924adb50458163a14dfe6ea9ed448.zip cpython-de821befd4a924adb50458163a14dfe6ea9ed448.tar.gz cpython-de821befd4a924adb50458163a14dfe6ea9ed448.tar.bz2 |
Issue #23571: PyErr_FormatV() and PyErr_SetObject() now always clear the
current exception because they can run arbitrary Python code and so no
exception must be set.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/Python/errors.c b/Python/errors.c index 1d64efd..17e3bcc 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -74,11 +74,11 @@ PyErr_SetObject(PyObject *exception, PyObject *value) if (value == NULL || !PyExceptionInstance_Check(value)) { /* We must normalize the value right now */ PyObject *args, *fixed_value; -#ifdef Py_DEBUG - /* in debug mode, PyEval_EvalFrameEx() fails with an assertion - error if an exception is set when it is called */ + + /* Issue #23571: PyEval_CallObject() must not be called with an + exception set */ PyErr_Clear(); -#endif + if (value == NULL || value == Py_None) args = PyTuple_New(0); else if (PyTuple_Check(value)) { @@ -778,13 +778,12 @@ PyErr_FormatV(PyObject *exception, const char *format, va_list vargs) { PyObject* string; -#ifdef Py_DEBUG - /* in debug mode, PyEval_EvalFrameEx() fails with an assertion error - if an exception is set when it is called */ + /* Issue #23571: PyUnicode_FromFormatV() must not be called with an + exception set, it calls arbitrary Python code like PyObject_Repr() */ PyErr_Clear(); -#endif string = PyUnicode_FromFormatV(format, vargs); + PyErr_SetObject(exception, string); Py_XDECREF(string); return NULL; |