add a __dict__ descr for IOBase (closes #12878)
diff --git a/Modules/_io/iobase.c b/Modules/_io/iobase.c
index f06f562..2c59d42 100644
--- a/Modules/_io/iobase.c
+++ b/Modules/_io/iobase.c
@@ -156,6 +156,19 @@
     return PyBool_FromLong(IS_CLOSED(self));
 }
 
+static PyObject *
+iobase_get_dict(PyObject *self)
+{
+    PyObject **dictptr = _PyObject_GetDictPtr(self);
+    PyObject *dict;
+    assert(dictptr);
+    dict = *dictptr;
+    if (dict == NULL)
+        dict = *dictptr = PyDict_New();
+    Py_XINCREF(dict);
+    return dict;
+}
+
 PyObject *
 _PyIOBase_check_closed(PyObject *self, PyObject *args)
 {
@@ -691,6 +704,7 @@
 };
 
 static PyGetSetDef iobase_getset[] = {
+    {"__dict__", iobase_get_dict, NULL, NULL},
     {"closed", (getter)iobase_closed_get, NULL, NULL},
     {NULL}
 };