[Python-checkins] cpython: Issue #22290: PyObject_Call() now fails with an assertion error when called

victor.stinner python-checkins at python.org
Fri Sep 5 01:16:44 CEST 2014


http://hg.python.org/cpython/rev/16e3d240456f
changeset:   92340:16e3d240456f
parent:      92337:648685f8d5e9
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Fri Sep 05 01:10:29 2014 +0200
summary:
  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.

files:
  Objects/abstract.c |  5 +++++
  1 files changed, 5 insertions(+), 0 deletions(-)


diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2074,6 +2074,11 @@
 {
     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"))

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list