@@ -2977,18 +2977,42 @@ static PyType_Spec arrayiter_spec = {
29772977
29782978/*********************** Install Module **************************/
29792979
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+
29803004/* No functions in array module. */
29813005static PyMethodDef a_methods [] = {
29823006 ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF
29833007 {NULL , NULL , 0 , NULL } /* Sentinel */
29843008};
29853009
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+ } \
29923016} while (0)
29933017
29943018static int
@@ -3059,6 +3083,9 @@ static struct PyModuleDef arraymodule = {
30593083 .m_doc = module_doc ,
30603084 .m_methods = a_methods ,
30613085 .m_slots = arrayslots ,
3086+ .m_traverse = array_traverse ,
3087+ .m_clear = array_clear ,
3088+ .m_free = array_free ,
30623089};
30633090
30643091
0 commit comments