diff Objects/typeobject.c @ 84706:5bd9db528aed

Issue #18408: PyObject_Str(), PyObject_Repr() and type_call() now fail with an assertion error if they are called with an exception set (PyErr_Occurred()). As PyEval_EvalFrameEx(), they may clear the current exception and so the caller looses its exception.
author Victor Stinner <victor.stinner@gmail.com>
date Thu, 18 Jul 2013 01:49:30 +0200
parents c2d90ff0780c
children a65856044ad4
line wrap: on
line diff
--- a/Objects/typeobject.c	Thu Jul 18 01:54:37 2013 +0200
+++ b/Objects/typeobject.c	Thu Jul 18 01:49:30 2013 +0200
@@ -736,6 +736,13 @@
         return NULL;
     }
 
+#ifdef Py_DEBUG
+    /* type_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());
+#endif
+
     obj = type->tp_new(type, args, kwds);
     if (obj != NULL) {
         /* Ugly exception: when the call was type(something),