diff --git a/Modules/_io/_iomodule.h b/Modules/_io/_iomodule.h index afd638a120ba08..b97215d89138b4 100644 --- a/Modules/_io/_iomodule.h +++ b/Modules/_io/_iomodule.h @@ -195,3 +195,11 @@ extern PyObject *_PyIOBase_cannot_pickle(PyObject *self, PyObject *args); #ifdef HAVE_WINDOWS_CONSOLE_IO extern char _PyIO_get_console_type(PyObject *); #endif + + +typedef struct { + PyObject_HEAD + + PyObject *dict; + PyObject *weakreflist; +} iobase; diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 7a0c516411c73b..b6dff7777a5b9a 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2428,6 +2428,7 @@ static int bufferediobase_traverse(PyObject *self, visitproc visit, void *arg) { Py_VISIT(Py_TYPE(self)); + Py_VISIT(((iobase *)self)->dict); return 0; } diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c index 14d48813aefe83..a489bc30e88535 100644 --- a/Modules/_io/iobase.c +++ b/Modules/_io/iobase.c @@ -26,12 +26,6 @@ class _io._RawIOBase "PyObject *" "clinic_state()->PyRawIOBase_Type" * IOBase class, an abstract class */ -typedef struct { - PyObject_HEAD - - PyObject *dict; - PyObject *weakreflist; -} iobase; PyDoc_STRVAR(iobase_doc, "The abstract base class for all I/O classes.\n" @@ -1040,6 +1034,7 @@ static int rawiobase_traverse(PyObject *self, visitproc visit, void *arg) { Py_VISIT(Py_TYPE(self)); + Py_VISIT(((iobase *)self)->dict); return 0; } diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index e858a1fb498f82..f736db1b232adb 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -171,6 +171,7 @@ static int textiobase_traverse(PyObject *self, visitproc visit, void *arg) { Py_VISIT(Py_TYPE(self)); + Py_VISIT(((iobase *)self)->dict); return 0; }