]> granicus.if.org Git - python/commitdiff
Issue #18408: PyObject_Call() now fails with an assertion error in debug mode
authorVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 15:50:07 +0000 (17:50 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Mon, 15 Jul 2013 15:50:07 +0000 (17:50 +0200)
if the function called failed whereas no exception was raised, to detect bugs
earlier.

Objects/abstract.c

index 244dcafc4b2b71ff9ebcc7ebb02b206e2ed5450d..6896600ebab21f93bb72dac763a02bf3002023ef 100644 (file)
@@ -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",