mirror of
https://github.com/python/cpython
synced 2026-09-29 12:10:30 +03:00
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:
parent
a12f624a9d
commit
970e719a7a
18 changed files with 83 additions and 114 deletions
|
|
@ -113,7 +113,6 @@ bytes(cdata)
|
|||
#ifdef MS_WIN32
|
||||
# include "pycore_modsupport.h" // _PyArg_NoKeywords()
|
||||
#endif
|
||||
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()
|
||||
|
||||
|
||||
#include <ffi.h>
|
||||
|
|
@ -185,7 +184,7 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
|
|||
DictRemoverObject *self = (DictRemoverObject *)myself;
|
||||
if (self->key && self->dict) {
|
||||
if (-1 == PyDict_DelItem(self->dict, self->key)) {
|
||||
_PyErr_WriteUnraisableMsg("on calling _ctypes.DictRemover", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on calling _ctypes.DictRemover");
|
||||
}
|
||||
Py_CLEAR(self->key);
|
||||
Py_CLEAR(self->dict);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
#include "Python.h"
|
||||
#include "pycore_call.h" // _PyObject_CallNoArgs()
|
||||
#include "pycore_ceval.h" // _PyEval_SetProfile()
|
||||
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
|
||||
#include "rotatingtree.h"
|
||||
|
|
@ -847,7 +846,7 @@ profiler_dealloc(ProfilerObject *op)
|
|||
if (op->flags & POF_ENABLED) {
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
if (_PyEval_SetProfile(tstate, NULL, NULL) < 0) {
|
||||
_PyErr_WriteUnraisableMsg("When destroying _lsprof profiler", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored when destroying _lsprof profiler");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1032,8 +1032,8 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate,
|
|||
Py_INCREF(op);
|
||||
(void) clear(op);
|
||||
if (_PyErr_Occurred(tstate)) {
|
||||
_PyErr_WriteUnraisableMsg("in tp_clear of",
|
||||
(PyObject*)Py_TYPE(op));
|
||||
PyErr_FormatUnraisable("Exception ignored in tp_clear of %s",
|
||||
Py_TYPE(op)->tp_name);
|
||||
}
|
||||
Py_DECREF(op);
|
||||
}
|
||||
|
|
@ -1344,7 +1344,7 @@ gc_collect_main(PyThreadState *tstate, int generation,
|
|||
_PyErr_Clear(tstate);
|
||||
}
|
||||
else {
|
||||
_PyErr_WriteUnraisableMsg("in garbage collection", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored in garbage collection");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1403,7 +1403,7 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
|
|||
"collected", collected,
|
||||
"uncollectable", uncollectable);
|
||||
if (info == NULL) {
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1411,7 +1411,7 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
|
|||
PyObject *phase_obj = PyUnicode_FromString(phase);
|
||||
if (phase_obj == NULL) {
|
||||
Py_XDECREF(info);
|
||||
PyErr_WriteUnraisable(NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored on invoking gc callbacks");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "pycore_fileutils.h" // _Py_abspath()
|
||||
#include "pycore_initconfig.h" // _PyStatus_EXCEPTION()
|
||||
#include "pycore_pathconfig.h" // _PyPathConfig_ReadGlobal()
|
||||
#include "pycore_pyerrors.h" // _PyErr_WriteUnraisableMsg()
|
||||
#include "pycore_pymem.h" // _PyMem_RawWcsdup()
|
||||
#include "pycore_pystate.h" // _PyThreadState_GET()
|
||||
|
||||
|
|
@ -911,7 +910,7 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
|
|||
) {
|
||||
Py_DECREF(co);
|
||||
Py_DECREF(dict);
|
||||
_PyErr_WriteUnraisableMsg("error evaluating initial values", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored in preparing getpath");
|
||||
return PyStatus_Error("error evaluating initial values");
|
||||
}
|
||||
|
||||
|
|
@ -920,13 +919,13 @@ _PyConfig_InitPathConfig(PyConfig *config, int compute_path_config)
|
|||
|
||||
if (!r) {
|
||||
Py_DECREF(dict);
|
||||
_PyErr_WriteUnraisableMsg("error evaluating path", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored in running getpath");
|
||||
return PyStatus_Error("error evaluating path");
|
||||
}
|
||||
Py_DECREF(r);
|
||||
|
||||
if (_PyConfig_FromDict(config, configDict) < 0) {
|
||||
_PyErr_WriteUnraisableMsg("reading getpath results", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored in reading getpath results");
|
||||
Py_DECREF(dict);
|
||||
return PyStatus_Error("error getting getpath results");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,8 +244,7 @@ report_wakeup_write_error(void *data)
|
|||
errno = (int) (intptr_t) data;
|
||||
PyObject *exc = PyErr_GetRaisedException();
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
_PyErr_WriteUnraisableMsg("when trying to write to the signal wakeup fd",
|
||||
NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored when trying to write to the signal wakeup fd");
|
||||
PyErr_SetRaisedException(exc);
|
||||
errno = save_errno;
|
||||
return 0;
|
||||
|
|
@ -262,7 +261,7 @@ report_wakeup_send_error(void* data)
|
|||
recognizes the error codes used by both GetLastError() and
|
||||
WSAGetLastError */
|
||||
PyErr_SetExcFromWindowsErr(PyExc_OSError, send_errno);
|
||||
_PyErr_WriteUnraisableMsg("when trying to send to the signal wakeup fd", NULL);
|
||||
PyErr_FormatUnraisable("Exception ignored when trying to send to the signal wakeup fd");
|
||||
PyErr_SetRaisedException(exc);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue