aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/gc_free_threading.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/gc_free_threading.c')
-rw-r--r--Python/gc_free_threading.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/Python/gc_free_threading.c b/Python/gc_free_threading.c
index 905a14f660e..5d264e407e1 100644
--- a/Python/gc_free_threading.c
+++ b/Python/gc_free_threading.c
@@ -1128,7 +1128,8 @@ call_weakref_callbacks(struct collection_state *state)
/* copy-paste of weakrefobject.c's handle_callback() */
PyObject *temp = PyObject_CallOneArg(callback, (PyObject *)wr);
if (temp == NULL) {
- PyErr_WriteUnraisable(callback);
+ PyErr_FormatUnraisable("Exception ignored while "
+ "calling weakref callback %R", callback);
}
else {
Py_DECREF(temp);
@@ -1447,7 +1448,8 @@ invoke_gc_callback(PyThreadState *tstate, const char *phase,
Py_INCREF(cb); /* make sure cb doesn't go away */
r = PyObject_Vectorcall(cb, stack, 2, NULL);
if (r == NULL) {
- PyErr_WriteUnraisable(cb);
+ PyErr_FormatUnraisable("Exception ignored while "
+ "calling GC callback %R", cb);
}
else {
Py_DECREF(r);
@@ -2029,13 +2031,14 @@ _PyGC_DumpShutdownStats(PyInterpreterState *interp)
"gc", NULL, message,
PyList_GET_SIZE(gcstate->garbage)))
{
- PyErr_WriteUnraisable(NULL);
+ PyErr_FormatUnraisable("Exception ignored in GC shutdown");
}
if (gcstate->debug & _PyGC_DEBUG_UNCOLLECTABLE) {
PyObject *repr = NULL, *bytes = NULL;
repr = PyObject_Repr(gcstate->garbage);
if (!repr || !(bytes = PyUnicode_EncodeFSDefault(repr))) {
- PyErr_WriteUnraisable(gcstate->garbage);
+ PyErr_FormatUnraisable("Exception ignored in GC shutdown "
+ "while formatting garbage");
}
else {
PySys_WriteStderr(
@@ -2243,9 +2246,12 @@ PyObject_GC_Del(void *op)
#ifdef Py_DEBUG
PyObject *exc = PyErr_GetRaisedException();
if (PyErr_WarnExplicitFormat(PyExc_ResourceWarning, "gc", 0,
- "gc", NULL, "Object of type %s is not untracked before destruction",
- ((PyObject*)op)->ob_type->tp_name)) {
- PyErr_WriteUnraisable(NULL);
+ "gc", NULL,
+ "Object of type %s is not untracked "
+ "before destruction",
+ Py_TYPE(op)->tp_name))
+ {
+ PyErr_FormatUnraisable("Exception ignored on object deallocation");
}
PyErr_SetRaisedException(exc);
#endif