Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
goto finally;
error:
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when clearing _datetime module");
finally:
PyErr_SetRaisedException(exc);
PyObject *exc = PyErr_GetRaisedException();
for (int i = 0; i < num_watchers; i++) {
if (PyCode_ClearWatcher(watcher_ids[i]) < 0) {
- PyErr_WriteUnraisable(Py_None);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "clearing code watcher");
break;
}
}
PyObject *exc = PyErr_GetRaisedException();
for (int i = 0; i < num_watchers; i++) {
if (PyFunction_ClearWatcher(watcher_ids[i]) < 0) {
- PyErr_WriteUnraisable(Py_None);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "clearing function watcher");
break;
}
}
PyObject *exc = PyErr_GetRaisedException();
for (int i = 0; i < num_watchers; i++) {
if (PyContext_ClearWatcher(watcher_ids[i]) < 0) {
- PyErr_WriteUnraisable(Py_None);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "clearing context watcher");
break;
}
}
{
/* 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
will probably only happen on Windows XP. */
PyErr_SetString(PyExc_PythonFinalizationError,
"I/O operations still in flight while destroying "
"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
probably about to exit, so we need not worry too much
about memory leaks. Leaking self prevents a potential
PyObject *copy = PyList_GetSlice(state->callbacks, 0, PyList_GET_SIZE(state->callbacks));
if (copy == NULL)
{
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "copying atexit callbacks");
return;
}
PyExc_RuntimeError,
"%R still has pending operation at "
"deallocation, the process may crash", self);
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when deallocating "
+ "overlapped operation %R", self);
}
}
PyErr_Format(PyExc_OSError,
"Signal %i ignored due to race condition",
i);
- PyErr_WriteUnraisable(Py_None);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "calling signal handler");
continue;
}
PyObject *arglist = NULL;
if (set_or_clear_managed_dict(obj, NULL, true) < 0) {
/* Must be out of memory */
assert(PyErr_Occurred() == PyExc_MemoryError);
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when "
+ "clearing an object managed dict");
/* Clear the dict */
PyDictObject *dict = _PyObject_GetManagedDict(obj);
Py_BEGIN_CRITICAL_SECTION2(dict, obj);
PyObject *tuple = PyTuple_New(num_weakrefs * 2);
if (tuple == NULL) {
_PyWeakref_ClearWeakRefsNoCallbacks(object);
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when clearing object weakrefs");
PyErr_SetRaisedException(exc);
return;
}
executor->jit_side_entry = NULL;
executor->jit_size = 0;
if (jit_free(memory, size)) {
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored when freeing JIT memory");
}
}
}