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

Skip to content

Commit 8f4ec8d

Browse files
committed
Issue #22290: PyObject_Call() now fails with an assertion error when called
with an exception set. This new assertion helps to understand if the exception was already set before calling the function or raised by the function.
1 parent 47e4042 commit 8f4ec8d

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Objects/abstract.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,11 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
20742074
{
20752075
ternaryfunc call;
20762076

2077+
/* PyObject_Call() must not be called with an exception set,
2078+
because it may clear it (directly or indirectly) and so the
2079+
caller looses its exception */
2080+
assert(!PyErr_Occurred());
2081+
20772082
if ((call = func->ob_type->tp_call) != NULL) {
20782083
PyObject *result;
20792084
if (Py_EnterRecursiveCall(" while calling a Python object"))

0 commit comments

Comments
 (0)