Skip to content

Commit 7fe9cad

Browse files
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464) (GH-26465)
* _testcapi.heapgctype: implement a traverse function since the type is defined with Py_TPFLAGS_HAVE_GC. * _decimal: PyDecSignalDictMixin_Type is no longer defined with Py_TPFLAGS_HAVE_GC since it has no traverse function. (cherry picked from commit 142e5c5) Co-authored-by: Victor Stinner <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent f097d23 commit 7fe9cad

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

Modules/_decimal/_decimal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,7 @@ static PyTypeObject PyDecSignalDictMixin_Type =
696696
PyObject_GenericGetAttr, /* tp_getattro */
697697
(setattrofunc) 0, /* tp_setattro */
698698
(PyBufferProcs *) 0, /* tp_as_buffer */
699-
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|
700-
Py_TPFLAGS_HAVE_GC, /* tp_flags */
699+
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
701700
0, /* tp_doc */
702701
0, /* tp_traverse */
703702
0, /* tp_clear */

Modules/_testcapimodule.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6595,6 +6595,13 @@ heapctype_init(PyObject *self, PyObject *args, PyObject *kwargs)
65956595
return 0;
65966596
}
65976597

6598+
static int
6599+
heapgcctype_traverse(HeapCTypeObject *self, visitproc visit, void *arg)
6600+
{
6601+
Py_VISIT(Py_TYPE(self));
6602+
return 0;
6603+
}
6604+
65986605
static void
65996606
heapgcctype_dealloc(HeapCTypeObject *self)
66006607
{
@@ -6608,6 +6615,7 @@ static PyType_Slot HeapGcCType_slots[] = {
66086615
{Py_tp_init, heapctype_init},
66096616
{Py_tp_members, heapctype_members},
66106617
{Py_tp_dealloc, heapgcctype_dealloc},
6618+
{Py_tp_traverse, heapgcctype_traverse},
66116619
{Py_tp_doc, (char*)heapgctype__doc__},
66126620
{0, 0},
66136621
};

0 commit comments

Comments
 (0)