Skip to content

Commit 6bcd0a0

Browse files
committed
fixup! bpo-33930: Fix segfault with deep recursion when cleaning method objects
1 parent a444686 commit 6bcd0a0

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Lib/test/test_exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,7 @@ def foo():
10361036
o = o.__dir__
10371037

10381038
foo()
1039+
support.gc_collect()
10391040

10401041
@cpython_only
10411042
def test_recursion_normalizing_exception(self):

Objects/methodobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static void
161161
meth_dealloc(PyCFunctionObject *m)
162162
{
163163
PyObject_GC_UnTrack(m);
164-
Py_TRASHCAN_SAFE_BEGIN(m);
164+
Py_TRASHCAN_BEGIN(m, meth_dealloc);
165165
if (m->m_weakreflist != NULL) {
166166
PyObject_ClearWeakRefs((PyObject*) m);
167167
}
@@ -171,7 +171,7 @@ meth_dealloc(PyCFunctionObject *m)
171171
Py_XDECREF(m->m_self);
172172
Py_XDECREF(m->m_module);
173173
PyObject_GC_Del(m);
174-
Py_TRASHCAN_SAFE_END(m);
174+
Py_TRASHCAN_END;
175175
}
176176

177177
static PyObject *

0 commit comments

Comments
 (0)