mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Restore changeset 5bd9db528aed (issue #18408)
"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."
This commit is contained in:
parent
c82bfd871f
commit
33824f6fd7
2 changed files with 22 additions and 0 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue