summaryrefslogtreecommitdiffstats
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-06 23:54:20 (GMT)
committerGitHub <noreply@github.com>2020-03-06 23:54:20 (GMT)
commit9e5d30cc99e34f4c3e7b2cd851de20816c9d1927 (patch)
tree71e726c4695b9b3b0a31d7d2516ce8ee83b52721 /Python/pylifecycle.c
parent7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520 (diff)
downloadcpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.zip
cpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.tar.gz
cpython-9e5d30cc99e34f4c3e7b2cd851de20816c9d1927.tar.bz2
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.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 23d74ee..9e3b257 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -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,6 +2241,8 @@ exit:
}
}
+#undef Py_FatalError
+
void _Py_NO_RETURN
Py_FatalError(const char *msg)
{
@@ -2248,6 +2250,12 @@ Py_FatalError(const char *msg)
}
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)
{
if (_PyStatus_IS_EXIT(status)) {