bpo-39882: Py_FatalError() logs the function name (GH-18819)

The Py_FatalError() function is replaced with a macro which logs
automatically the name of the current function, unless the
Py_LIMITED_API macro is defined.

Changes:

* Add _Py_FatalErrorFunc() function.
* Remove the function name from the message of Py_FatalError() calls
  which included the function name.
* Update tests.
This commit is contained in:
Victor Stinner 2020-03-07 00:54:20 +01:00 committed by GitHub
parent 7b3c252dc7
commit 9e5d30cc99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 112 additions and 69 deletions

View file

@ -1611,10 +1611,10 @@ Py_EndInterpreter(PyThreadState *tstate)
PyInterpreterState *interp = tstate->interp;
if (tstate != _PyThreadState_GET()) {
Py_FatalError("Py_EndInterpreter: thread is not current");
Py_FatalError("thread is not current");
}
if (tstate->frame != NULL) {
Py_FatalError("Py_EndInterpreter: thread still has a frame");
Py_FatalError("thread still has a frame");
}
interp->finalizing = 1;
@ -1624,7 +1624,7 @@ Py_EndInterpreter(PyThreadState *tstate)
call_py_exitfuncs(tstate);
if (tstate != interp->tstate_head || tstate->next != NULL) {
Py_FatalError("Py_EndInterpreter: not the last thread");
Py_FatalError("not the last thread");
}
_PyImport_Cleanup(tstate);
@ -2241,12 +2241,20 @@ exit:
}
}
#undef Py_FatalError
void _Py_NO_RETURN
Py_FatalError(const char *msg)
{
fatal_error(NULL, msg, -1);
}
void _Py_NO_RETURN
_Py_FatalErrorFunc(const char *func, const char *msg)
{
fatal_error(func, msg, -1);
}
void _Py_NO_RETURN
Py_ExitStatusException(PyStatus status)
{