bpo-40077: Add traverse/clear/free to arraymodule (GH-24066)
This commit is contained in:
parent
6613676861
commit
b8eb376590
|
@ -2977,6 +2977,30 @@ static PyType_Spec arrayiter_spec = {
|
||||||
|
|
||||||
/*********************** Install Module **************************/
|
/*********************** Install Module **************************/
|
||||||
|
|
||||||
|
static int
|
||||||
|
array_traverse(PyObject *module, visitproc visit, void *arg)
|
||||||
|
{
|
||||||
|
array_state *state = get_array_state(module);
|
||||||
|
Py_VISIT(state->ArrayType);
|
||||||
|
Py_VISIT(state->ArrayIterType);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
array_clear(PyObject *module)
|
||||||
|
{
|
||||||
|
array_state *state = get_array_state(module);
|
||||||
|
Py_CLEAR(state->ArrayType);
|
||||||
|
Py_CLEAR(state->ArrayIterType);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
array_free(void *module)
|
||||||
|
{
|
||||||
|
array_clear((PyObject *)module);
|
||||||
|
}
|
||||||
|
|
||||||
/* No functions in array module. */
|
/* No functions in array module. */
|
||||||
static PyMethodDef a_methods[] = {
|
static PyMethodDef a_methods[] = {
|
||||||
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
|
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
|
||||||
|
@ -2985,7 +3009,7 @@ static PyMethodDef a_methods[] = {
|
||||||
|
|
||||||
#define CREATE_TYPE(module, type, spec) \
|
#define CREATE_TYPE(module, type, spec) \
|
||||||
do { \
|
do { \
|
||||||
type = (PyTypeObject *)PyType_FromModuleAndSpec(m, spec, NULL); \
|
type = (PyTypeObject *)PyType_FromModuleAndSpec(module, spec, NULL); \
|
||||||
if (type == NULL) { \
|
if (type == NULL) { \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
|
@ -3059,6 +3083,9 @@ static struct PyModuleDef arraymodule = {
|
||||||
.m_doc = module_doc,
|
.m_doc = module_doc,
|
||||||
.m_methods = a_methods,
|
.m_methods = a_methods,
|
||||||
.m_slots = arrayslots,
|
.m_slots = arrayslots,
|
||||||
|
.m_traverse = array_traverse,
|
||||||
|
.m_clear = array_clear,
|
||||||
|
.m_free = array_free,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue