aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/exceptions.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index c6a7aa4aecc..714039ee1ab 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -89,9 +89,14 @@ BaseException_clear(PyBaseExceptionObject *self)
static void
BaseException_dealloc(PyBaseExceptionObject *self)
{
- _PyObject_GC_UNTRACK(self);
+ PyObject_GC_UnTrack(self);
+ // bpo-44348: The trashcan mecanism prevents stack overflow when deleting
+ // long chains of exceptions. For example, exceptions can be chained
+ // through the __context__ attributes or the __traceback__ attribute.
+ Py_TRASHCAN_BEGIN(self, BaseException_dealloc)
BaseException_clear(self);
Py_TYPE(self)->tp_free((PyObject *)self);
+ Py_TRASHCAN_END
}
static int