mirror of
https://github.com/python/cpython.git
synced 2025-12-15 21:44:50 +00:00
Issue #18408: PyObject_Call() now fails with an assertion error in debug mode
if the function called failed whereas no exception was raised, to detect bugs earlier.
This commit is contained in:
parent
33283ba300
commit
3de5869864
1 changed files with 7 additions and 1 deletions
|
|
@ -2104,10 +2104,16 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
|
|||
return NULL;
|
||||
result = (*call)(func, arg, kw);
|
||||
Py_LeaveRecursiveCall();
|
||||
if (result == NULL && !PyErr_Occurred())
|
||||
#ifdef NDEBUG
|
||||
if (result == NULL && !PyErr_Occurred()) {
|
||||
PyErr_SetString(
|
||||
PyExc_SystemError,
|
||||
"NULL result without error in PyObject_Call");
|
||||
}
|
||||
#else
|
||||
if (result == NULL)
|
||||
assert(PyErr_Occurred());
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
PyErr_Format(PyExc_TypeError, "'%.200s' object is not callable",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue