mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
gh-129354: Use PyErr_FormatUnraisable() function (#129435)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
This commit is contained in:
parent
5ab9604683
commit
4e47e05045
9 changed files with 21 additions and 15 deletions
|
|
@ -226,7 +226,7 @@ clear_current_module(PyInterpreterState *interp, PyObject *expected)
|
||||||
goto finally;
|
goto finally;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when clearing _datetime module");
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
PyErr_SetRaisedException(exc);
|
PyErr_SetRaisedException(exc);
|
||||||
|
|
|
||||||
|
|
@ -428,7 +428,8 @@ allocate_too_many_code_watchers(PyObject *self, PyObject *args)
|
||||||
PyObject *exc = PyErr_GetRaisedException();
|
PyObject *exc = PyErr_GetRaisedException();
|
||||||
for (int i = 0; i < num_watchers; i++) {
|
for (int i = 0; i < num_watchers; i++) {
|
||||||
if (PyCode_ClearWatcher(watcher_ids[i]) < 0) {
|
if (PyCode_ClearWatcher(watcher_ids[i]) < 0) {
|
||||||
PyErr_WriteUnraisable(Py_None);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"clearing code watcher");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -609,7 +610,8 @@ allocate_too_many_func_watchers(PyObject *self, PyObject *args)
|
||||||
PyObject *exc = PyErr_GetRaisedException();
|
PyObject *exc = PyErr_GetRaisedException();
|
||||||
for (int i = 0; i < num_watchers; i++) {
|
for (int i = 0; i < num_watchers; i++) {
|
||||||
if (PyFunction_ClearWatcher(watcher_ids[i]) < 0) {
|
if (PyFunction_ClearWatcher(watcher_ids[i]) < 0) {
|
||||||
PyErr_WriteUnraisable(Py_None);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"clearing function watcher");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -755,7 +757,8 @@ allocate_too_many_context_watchers(PyObject *self, PyObject *args)
|
||||||
PyObject *exc = PyErr_GetRaisedException();
|
PyObject *exc = PyErr_GetRaisedException();
|
||||||
for (int i = 0; i < num_watchers; i++) {
|
for (int i = 0; i < num_watchers; i++) {
|
||||||
if (PyContext_ClearWatcher(watcher_ids[i]) < 0) {
|
if (PyContext_ClearWatcher(watcher_ids[i]) < 0) {
|
||||||
PyErr_WriteUnraisable(Py_None);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"clearing context watcher");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -171,17 +171,16 @@ overlapped_dealloc(OverlappedObject *self)
|
||||||
{
|
{
|
||||||
/* The operation is no longer pending -- nothing to do. */
|
/* The operation is no longer pending -- nothing to do. */
|
||||||
}
|
}
|
||||||
else if (_Py_IsInterpreterFinalizing(_PyInterpreterState_GET()))
|
else if (_Py_IsInterpreterFinalizing(_PyInterpreterState_GET())) {
|
||||||
{
|
|
||||||
/* The operation is still pending -- give a warning. This
|
/* The operation is still pending -- give a warning. This
|
||||||
will probably only happen on Windows XP. */
|
will probably only happen on Windows XP. */
|
||||||
PyErr_SetString(PyExc_PythonFinalizationError,
|
PyErr_SetString(PyExc_PythonFinalizationError,
|
||||||
"I/O operations still in flight while destroying "
|
"I/O operations still in flight while destroying "
|
||||||
"Overlapped object, the process may crash");
|
"Overlapped object, the process may crash");
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when deallocating "
|
||||||
|
"overlapped operation %R", self);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
/* The operation is still pending, but the process is
|
/* The operation is still pending, but the process is
|
||||||
probably about to exit, so we need not worry too much
|
probably about to exit, so we need not worry too much
|
||||||
about memory leaks. Leaking self prevents a potential
|
about memory leaks. Leaking self prevents a potential
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,8 @@ atexit_callfuncs(struct atexit_state *state)
|
||||||
PyObject *copy = PyList_GetSlice(state->callbacks, 0, PyList_GET_SIZE(state->callbacks));
|
PyObject *copy = PyList_GetSlice(state->callbacks, 0, PyList_GET_SIZE(state->callbacks));
|
||||||
if (copy == NULL)
|
if (copy == NULL)
|
||||||
{
|
{
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"copying atexit callbacks");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -759,7 +759,8 @@ Overlapped_dealloc(OverlappedObject *self)
|
||||||
PyExc_RuntimeError,
|
PyExc_RuntimeError,
|
||||||
"%R still has pending operation at "
|
"%R still has pending operation at "
|
||||||
"deallocation, the process may crash", self);
|
"deallocation, the process may crash", self);
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when deallocating "
|
||||||
|
"overlapped operation %R", self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1837,7 +1837,8 @@ _PyErr_CheckSignalsTstate(PyThreadState *tstate)
|
||||||
PyErr_Format(PyExc_OSError,
|
PyErr_Format(PyExc_OSError,
|
||||||
"Signal %i ignored due to race condition",
|
"Signal %i ignored due to race condition",
|
||||||
i);
|
i);
|
||||||
PyErr_WriteUnraisable(Py_None);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"calling signal handler");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PyObject *arglist = NULL;
|
PyObject *arglist = NULL;
|
||||||
|
|
|
||||||
|
|
@ -7351,7 +7351,8 @@ PyObject_ClearManagedDict(PyObject *obj)
|
||||||
if (set_or_clear_managed_dict(obj, NULL, true) < 0) {
|
if (set_or_clear_managed_dict(obj, NULL, true) < 0) {
|
||||||
/* Must be out of memory */
|
/* Must be out of memory */
|
||||||
assert(PyErr_Occurred() == PyExc_MemoryError);
|
assert(PyErr_Occurred() == PyExc_MemoryError);
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when "
|
||||||
|
"clearing an object managed dict");
|
||||||
/* Clear the dict */
|
/* Clear the dict */
|
||||||
PyDictObject *dict = _PyObject_GetManagedDict(obj);
|
PyDictObject *dict = _PyObject_GetManagedDict(obj);
|
||||||
Py_BEGIN_CRITICAL_SECTION2(dict, obj);
|
Py_BEGIN_CRITICAL_SECTION2(dict, obj);
|
||||||
|
|
|
||||||
|
|
@ -1042,7 +1042,7 @@ PyObject_ClearWeakRefs(PyObject *object)
|
||||||
PyObject *tuple = PyTuple_New(num_weakrefs * 2);
|
PyObject *tuple = PyTuple_New(num_weakrefs * 2);
|
||||||
if (tuple == NULL) {
|
if (tuple == NULL) {
|
||||||
_PyWeakref_ClearWeakRefsNoCallbacks(object);
|
_PyWeakref_ClearWeakRefsNoCallbacks(object);
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when clearing object weakrefs");
|
||||||
PyErr_SetRaisedException(exc);
|
PyErr_SetRaisedException(exc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -563,7 +563,7 @@ _PyJIT_Free(_PyExecutorObject *executor)
|
||||||
executor->jit_side_entry = NULL;
|
executor->jit_side_entry = NULL;
|
||||||
executor->jit_size = 0;
|
executor->jit_size = 0;
|
||||||
if (jit_free(memory, size)) {
|
if (jit_free(memory, size)) {
|
||||||
PyErr_WriteUnraisable(NULL);
|
PyErr_FormatUnraisable("Exception ignored when freeing JIT memory");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue