]> granicus.if.org Git - python/commitdiff
Issue #22290: PyObject_Call() now fails with an assertion error when called
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Sep 2014 23:10:29 +0000 (01:10 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 4 Sep 2014 23:10:29 +0000 (01:10 +0200)
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.

Objects/abstract.c

index 783a83c3ed091e3e015e6d596e0412fce980b3f3..ec599723ac659fef8718eb4166c90cc3f706cf27 100644 (file)
@@ -2074,6 +2074,11 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)
 {
     ternaryfunc call;
 
+    /* PyObject_Call() must not be called with an exception set,
+       because it may clear it (directly or indirectly) and so the
+       caller looses its exception */
+    assert(!PyErr_Occurred());
+
     if ((call = func->ob_type->tp_call) != NULL) {
         PyObject *result;
         if (Py_EnterRecursiveCall(" while calling a Python object"))