aboutsummaryrefslogtreecommitdiff
path: root/Objects/typeobject.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-18 01:49:30 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-18 01:49:30 +0200
commit8e4783273709df286fb6a83506ead4df8483a695 (patch)
tree007d4eca024d94eed5443aac681da95e5c5e7feb /Objects/typeobject.c
parent4abda5d5b08f5ed09f4c72e7ba9726f89aaf8780 (diff)
downloadcpython3-8e4783273709df286fb6a83506ead4df8483a695.tar.gz
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.
Diffstat (limited to 'Objects/typeobject.c')
-rw-r--r--Objects/typeobject.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index c970ada1df..0eea38443f 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -736,6 +736,13 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
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),