gh-108082: Use PyErr_FormatUnraisable() (GH-111580)

Replace most of calls of _PyErr_WriteUnraisableMsg() and some
calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().

Co-authored-by: Victor Stinner <vstinner@python.org>
This commit is contained in:
Serhiy Storchaka 2023-11-02 11:16:34 +02:00 committed by GitHub
parent a12f624a9d
commit 970e719a7a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 83 additions and 114 deletions

View file

@ -133,7 +133,6 @@ any DWARF information available for them).
#include "pycore_ceval.h" // _PyPerf_Callbacks
#include "pycore_frame.h"
#include "pycore_interp.h"
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()
#ifdef PY_HAVE_PERF_TRAMPOLINE
@ -236,8 +235,7 @@ new_code_arena(void)
0); // offset (not used here)
if (!memory) {
PyErr_SetFromErrno(PyExc_OSError);
_PyErr_WriteUnraisableMsg(
"Failed to create new mmap for perf trampoline", NULL);
PyErr_FormatUnraisable("Failed to create new mmap for perf trampoline");
perf_status = PERF_STATUS_FAILED;
return -1;
}
@ -261,9 +259,8 @@ new_code_arena(void)
if (res == -1) {
PyErr_SetFromErrno(PyExc_OSError);
munmap(memory, mem_size);
_PyErr_WriteUnraisableMsg(
"Failed to set mmap for perf trampoline to PROT_READ | PROT_EXEC",
NULL);
PyErr_FormatUnraisable("Failed to set mmap for perf trampoline to "
"PROT_READ | PROT_EXEC");
return -1;
}
@ -277,8 +274,7 @@ new_code_arena(void)
if (new_arena == NULL) {
PyErr_NoMemory();
munmap(memory, mem_size);
_PyErr_WriteUnraisableMsg("Failed to allocate new code arena struct",
NULL);
PyErr_FormatUnraisable("Failed to allocate new code arena struct for perf trampoline");
return -1;
}