[Python-checkins] bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
miss-islington
webhook-mailer at python.org
Mon May 31 07:33:36 EDT 2021
https://github.com/python/cpython/commit/46b16d0bdbb1722daed10389e27226a2370f1635
commit: 46b16d0bdbb1722daed10389e27226a2370f1635
branch: 3.9
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2021-05-31T04:33:31-07:00
summary:
bpo-44263: Fix _decimal and _testcapi GC protocol (GH-26464)
* _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 142e5c5445c019542246d93fe2f9e195d3131686)
Co-authored-by: Victor Stinner <vstinner at python.org>
files:
M Modules/_decimal/_decimal.c
M Modules/_testcapimodule.c
diff --git a/Modules/_decimal/_decimal.c b/Modules/_decimal/_decimal.c
index fb4e020f1260e6..d80d7915507d9f 100644
--- a/Modules/_decimal/_decimal.c
+++ b/Modules/_decimal/_decimal.c
@@ -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 */
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index f4e04e77636cfb..4f6f193202b9b4 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -6257,6 +6257,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)
{
@@ -6270,6 +6277,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},
};
More information about the Python-checkins
mailing list