From 4ac9c00cff2218e56d0d7f6385c4a0fbf9bcd20f Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 19 Dec 2013 13:47:35 +0100 Subject: [PATCH] Better assertion in PyObject_Call() to detect functions returning a result with an exception set (invalid state). --- Objects/abstract.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/abstract.c b/Objects/abstract.c index a9c6d6b9e5..38ddb0f3df 100644 --- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -2073,7 +2073,8 @@ PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) "NULL result without error in PyObject_Call"); } #else - assert(result != NULL || PyErr_Occurred()); + assert((result != NULL && !PyErr_Occurred()) + || (result == NULL && PyErr_Occurred())); #endif return result; } -- 2.40.0