@@ -2977,18 +2977,42 @@ static PyType_Spec arrayiter_spec = {
2977
2977
2978
2978
/*********************** Install Module **************************/
2979
2979
2980
+ static int
2981
+ array_traverse (PyObject * module , visitproc visit , void * arg )
2982
+ {
2983
+ array_state * state = get_array_state (module );
2984
+ Py_VISIT (state -> ArrayType );
2985
+ Py_VISIT (state -> ArrayIterType );
2986
+ return 0 ;
2987
+ }
2988
+
2989
+ static int
2990
+ array_clear (PyObject * module )
2991
+ {
2992
+ array_state * state = get_array_state (module );
2993
+ Py_CLEAR (state -> ArrayType );
2994
+ Py_CLEAR (state -> ArrayIterType );
2995
+ return 0 ;
2996
+ }
2997
+
2998
+ static void
2999
+ array_free (void * module )
3000
+ {
3001
+ array_clear ((PyObject * )module );
3002
+ }
3003
+
2980
3004
/* No functions in array module. */
2981
3005
static PyMethodDef a_methods [] = {
2982
3006
ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
2983
3007
{NULL , NULL , 0 , NULL } /* Sentinel */
2984
3008
};
2985
3009
2986
- #define CREATE_TYPE (module , type , spec ) \
2987
- do { \
2988
- type = (PyTypeObject *)PyType_FromModuleAndSpec(m , spec, NULL); \
2989
- if (type == NULL) { \
2990
- return -1; \
2991
- } \
3010
+ #define CREATE_TYPE (module , type , spec ) \
3011
+ do { \
3012
+ type = (PyTypeObject *)PyType_FromModuleAndSpec(module , spec, NULL); \
3013
+ if (type == NULL) { \
3014
+ return -1; \
3015
+ } \
2992
3016
} while (0)
2993
3017
2994
3018
static int
@@ -3059,6 +3083,9 @@ static struct PyModuleDef arraymodule = {
3059
3083
.m_doc = module_doc ,
3060
3084
.m_methods = a_methods ,
3061
3085
.m_slots = arrayslots ,
3086
+ .m_traverse = array_traverse ,
3087
+ .m_clear = array_clear ,
3088
+ .m_free = array_free ,
3062
3089
};
3063
3090
3064
3091
0 commit comments