[Python-checkins] cpython: Issue #23571: PyErr_FormatV() and PyErr_SetObject() now always clear the

victor.stinner python-checkins at python.org
Tue Mar 24 12:41:32 CET 2015


https://hg.python.org/cpython/rev/2e14ca478a57
changeset: 95156:2e14ca478a57
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Mar 24 12:41:23 2015 +0100
summary:
 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.
files:
 Python/errors.c | 15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Python/errors.c b/Python/errors.c
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -74,11 +74,11 @@
 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 @@
 {
 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;
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /