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.
diff --git a/Python/import.c b/Python/import.c
index 392d711..c4a19bc 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -310,7 +310,7 @@
{
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
if (interp->modules == NULL) {
- Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
+ Py_FatalError("no module dictionary");
}
return interp->modules;
}
@@ -982,8 +982,7 @@
_Py_IDENTIFIER(_get_sourcefile);
if (interp == NULL) {
- Py_FatalError("PyImport_ExecCodeModuleWithPathnames: "
- "no interpreter!");
+ Py_FatalError("no interpreter!");
}
external= PyObject_GetAttrString(interp->importlib,