Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f243ee4

Browse files
committed
Issue #18408: add more assertions on PyErr_Occurred() in ceval.c to detect bugs
earlier
1 parent ceceaa0 commit f243ee4

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

Objects/abstract.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,8 +2111,7 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
21112111
"NULL result without error in PyObject_Call");
21122112
}
21132113
#else
2114-
if (result == NULL)
2115-
assert(PyErr_Occurred());
2114+
assert(result != NULL || PyErr_Occurred());
21162115
#endif
21172116
return result;
21182117
}

Python/ceval.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,6 +4216,8 @@ call_function(PyObject ***pp_stack, int oparg
42164216
READ_TIMESTAMP(*pintr1);
42174217
Py_DECREF(func);
42184218
}
4219+
assert((x != NULL && !PyErr_Occurred())
4220+
|| (x == NULL && PyErr_Occurred()));
42194221

42204222
/* Clear the stack of the function object. Also removes
42214223
the arguments in case they weren't consumed already
@@ -4509,6 +4511,8 @@ ext_do_call(PyObject *func, PyObject ***pp_stack, int flags, int na, int nk)
45094511
Py_XDECREF(callargs);
45104512
Py_XDECREF(kwdict);
45114513
Py_XDECREF(stararg);
4514+
assert((result != NULL && !PyErr_Occurred())
4515+
|| (result == NULL && PyErr_Occurred()));
45124516
return result;
45134517
}
45144518

0 commit comments

Comments
 (0)