diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 23:41:08 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-17 23:41:08 (GMT) |
commit | ace47d7efd2e2ab708fdc25936e9a8f85e08b6d3 (patch) | |
tree | 6493906040cfe23cb98638bdb712226479730ad7 /Python/errors.c | |
parent | e9af4cfaced93ea9ec37bb448dd57b8c2014bdaf (diff) | |
download | cpython-ace47d7efd2e2ab708fdc25936e9a8f85e08b6d3.zip cpython-ace47d7efd2e2ab708fdc25936e9a8f85e08b6d3.tar.gz cpython-ace47d7efd2e2ab708fdc25936e9a8f85e08b6d3.tar.bz2 |
Issue #18408: PyEval_EvalFrameEx() and PyEval_CallObjectWithKeywords() now fail
with an assertion error if they are called with an exception set
(PyErr_Occurred()).
If these functions are called with an exception set, the exception may be
cleared and so the caller looses its exception.
Add also assertions to PyEval_CallObjectWithKeywords() and call_function() to
check if the function succeed with no exception set, or the function failed
with an exception set.
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c index c693b78..b0f8b18 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -71,6 +71,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 */ + PyErr_Clear(); +#endif if (value == NULL || value == Py_None) args = PyTuple_New(0); else if (PyTuple_Check(value)) { @@ -707,6 +712,12 @@ PyErr_Format(PyObject *exception, const char *format, ...) va_start(vargs); #endif +#ifdef Py_DEBUG + /* in debug mode, PyEval_EvalFrameEx() fails with an assertion error + if an exception is set when it is called */ + PyErr_Clear(); +#endif + string = PyUnicode_FromFormatV(format, vargs); PyErr_SetObject(exception, string); Py_XDECREF(string); |