Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-35711: When asserting !PyErr_Occurred, output error before crashing #11513

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions Objects/call.c
Expand Up @@ -88,8 +88,12 @@ _PyObject_FastCallDict(PyObject *callable, PyObject *const *args, Py_ssize_t nar
{
/* _PyObject_FastCallDict() must not be called with an exception set,
because it can clear it (directly or indirectly) and so the
caller loses its exception */
assert(!PyErr_Occurred());
caller loses its exception. But do print something about the error
that would have been clobbered before crashing. */
if (PyErr_Occurred()) {
PyErr_Print();
assert(!PyErr_Occurred());
}

assert(callable != NULL);
assert(nargs >= 0);
Expand Down Expand Up @@ -141,8 +145,12 @@ _PyObject_FastCallKeywords(PyObject *callable, PyObject *const *stack, Py_ssize_
{
/* _PyObject_FastCallKeywords() must not be called with an exception set,
because it can clear it (directly or indirectly) and so the
caller loses its exception */
assert(!PyErr_Occurred());
caller loses its exception. But do print something about the error that
would have been clobbered before crashing. */
if (PyErr_Occurred()) {
PyErr_Print();
assert(!PyErr_Occurred());
}

assert(nargs >= 0);
assert(kwnames == NULL || PyTuple_CheckExact(kwnames));
Expand Down