]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
authorVictor Stinner <vstinner@python.org>
Mon, 31 May 2021 11:10:31 +0000 (13:10 +0200)
committerGitHub <noreply@github.com>
Mon, 31 May 2021 11:10:31 +0000 (13:10 +0200)
* _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.

Modules/_decimal/_decimal.c
Modules/_testcapimodule.c

index 9b89fa40c926b173c734612dc4fb08026465e150..e2979a577c96c71db5e932a929126fe6456d6fc1 100644 (file)
@@ -696,8 +696,7 @@ static PyTypeObject PyDecSignalDictMixin_Type =
     PyObject_GenericGetAttr,                  /* tp_getattro */
     (setattrofunc) 0,                         /* tp_setattro */
     (PyBufferProcs *) 0,                      /* tp_as_buffer */
-    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|
-    Py_TPFLAGS_HAVE_GC,                       /* tp_flags */
+    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE,   /* tp_flags */
     0,                                        /* tp_doc */
     0,                                        /* tp_traverse */
     0,                                        /* tp_clear */
index 0c48accf2803a8d133d2b4d11151c0d08ada5da7..ab47949d89e6351027b4faa8c0330c80b44d01df 100644 (file)
@@ -6548,6 +6548,13 @@ heapctype_init(PyObject *self, PyObject *args, PyObject *kwargs)
     return 0;
 }
 
+static int
+heapgcctype_traverse(HeapCTypeObject *self, visitproc visit, void *arg)
+{
+    Py_VISIT(Py_TYPE(self));
+    return 0;
+}
+
 static void
 heapgcctype_dealloc(HeapCTypeObject *self)
 {
@@ -6561,6 +6568,7 @@ static PyType_Slot HeapGcCType_slots[] = {
     {Py_tp_init, heapctype_init},
     {Py_tp_members, heapctype_members},
     {Py_tp_dealloc, heapgcctype_dealloc},
+    {Py_tp_traverse, heapgcctype_traverse},
     {Py_tp_doc, (char*)heapgctype__doc__},
     {0, 0},
 };