Skip to content

Commit c1926a6

Browse files
Visit and clear heap types at module level
1 parent 0570ae0 commit c1926a6

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Modules/_io/_iomodule.c

+18
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,15 @@ iomodule_traverse(PyObject *mod, visitproc visit, void *arg) {
582582
return 0;
583583
Py_VISIT(state->locale_module);
584584
Py_VISIT(state->unsupported_operation);
585+
586+
Py_VISIT(state->PyBufferedRWPair_Type);
587+
Py_VISIT(state->PyBufferedRandom_Type);
588+
Py_VISIT(state->PyBufferedReader_Type);
589+
Py_VISIT(state->PyBufferedWriter_Type);
590+
Py_VISIT(state->PyBytesIO_Type);
591+
Py_VISIT(state->PyFileIO_Type);
592+
Py_VISIT(state->PyStringIO_Type);
593+
Py_VISIT(state->PyTextIOWrapper_Type);
585594
return 0;
586595
}
587596

@@ -594,6 +603,15 @@ iomodule_clear(PyObject *mod) {
594603
if (state->locale_module != NULL)
595604
Py_CLEAR(state->locale_module);
596605
Py_CLEAR(state->unsupported_operation);
606+
607+
Py_CLEAR(state->PyBufferedRWPair_Type);
608+
Py_CLEAR(state->PyBufferedRandom_Type);
609+
Py_CLEAR(state->PyBufferedReader_Type);
610+
Py_CLEAR(state->PyBufferedWriter_Type);
611+
Py_CLEAR(state->PyBytesIO_Type);
612+
Py_CLEAR(state->PyFileIO_Type);
613+
Py_CLEAR(state->PyStringIO_Type);
614+
Py_CLEAR(state->PyTextIOWrapper_Type);
597615
return 0;
598616
}
599617

Modules/_io/bufferedio.c

+1
Original file line numberDiff line numberDiff line change
@@ -2122,6 +2122,7 @@ _io_BufferedRWPair___init___impl(rwpair *self, PyObject *reader,
21222122
static int
21232123
bufferedrwpair_traverse(rwpair *self, visitproc visit, void *arg)
21242124
{
2125+
Py_VISIT(Py_TYPE(self));
21252126
Py_VISIT(self->dict);
21262127
return 0;
21272128
}

0 commit comments

Comments
 (0)