[Python-checkins] cpython: Issue #23571: In debug mode, _Py_CheckFunctionResult() now calls
victor.stinner
python-checkins at python.org
Tue Mar 24 14:07:22 CET 2015
https://hg.python.org/cpython/rev/850b9dcd0534
changeset: 95158:850b9dcd0534
parent: 95156:2e14ca478a57
user: Victor Stinner <victor.stinner at gmail.com>
date: Tue Mar 24 12:53:59 2015 +0100
summary:
Issue #23571: In debug mode, _Py_CheckFunctionResult() now calls
Py_FatalError() instead of using an assertion in debug mode. Py_FatalError()
displays the current exception and the traceback which contain more information
than just the assertion error.
files:
Objects/abstract.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2080,16 +2080,6 @@
assert((func != NULL) ^ (where != NULL));
-#ifndef NDEBUG
- /* In debug mode: abort() with an assertion error. Use two different
- assertions, so if an assertion fails, it's possible to know
- if result was set or not and if an exception was raised or not. */
- if (result != NULL)
- assert(!err_occurred);
- else
- assert(err_occurred);
-#endif
-
if (result == NULL) {
if (!err_occurred) {
if (func)
@@ -2100,7 +2090,7 @@
PyErr_Format(PyExc_SystemError,
"%s returned NULL without setting an error",
where);
- return NULL;
+ goto error;
}
}
else {
@@ -2119,10 +2109,17 @@
"%s returned a result with an error set",
where);
_PyErr_ChainExceptions(exc, val, tb);
- return NULL;
+ goto error;
}
}
return result;
+
+error:
+#ifdef Py_DEBUG
+ /* Ensure that the bug is catched in debug mode */
+ Py_FatalError("Function result is invalid");
+#endif
+ return NULL;
}
PyObject *
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list