summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 0aec5aa..9beb1a4 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -1102,7 +1102,7 @@ static void
_assert_exception_type_is_redundant(PyObject* type, PyObject* val)
{
if (type == NULL || type == Py_None) {
- assert(val == NULL || val == Py_None);
+ assert(val == type);
}
else {
assert(PyExceptionInstance_Check(val));
@@ -3738,7 +3738,9 @@ check_eval_breaker:
TARGET(JUMP_IF_NOT_EXC_MATCH) {
PyObject *right = POP();
- PyObject *left = TOP();
+ ASSERT_EXC_TYPE_IS_REDUNDANT(TOP(), SECOND());
+ PyObject *left = SECOND();
+ assert(PyExceptionInstance_Check(left));
if (check_except_type_valid(tstate, right) < 0) {
Py_DECREF(right);
goto error;
@@ -4198,7 +4200,13 @@ check_eval_breaker:
ASSERT_EXC_TYPE_IS_REDUNDANT(type, value);
_PyErr_StackItem *exc_info = tstate->exc_info;
SET_THIRD(exc_info->exc_traceback);
- SET_SECOND(exc_info->exc_value);
+ if (exc_info->exc_value != NULL) {
+ SET_SECOND(exc_info->exc_value);
+ }
+ else {
+ Py_INCREF(Py_None);
+ SET_SECOND(Py_None);
+ }
if (exc_info->exc_type != NULL) {
SET_TOP(exc_info->exc_type);
}
@@ -5916,7 +5924,9 @@ do_raise(PyThreadState *tstate, PyObject *exc, PyObject *cause)
type = exc_info->exc_type;
value = exc_info->exc_value;
tb = exc_info->exc_traceback;
- if (Py_IsNone(type) || type == NULL) {
+ assert(((Py_IsNone(value) || value == NULL)) ==
+ ((Py_IsNone(type) || type == NULL)));
+ if (Py_IsNone(value) || value == NULL) {
_PyErr_SetString(tstate, PyExc_RuntimeError,
"No active exception to reraise");
return 0;