summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io')
-rw-r--r--Modules/_io/iobase.c14
1 files changed, 14 insertions, 0 deletions
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 @@ iobase_closed_get(PyObject *self, void *context)
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 PyMethodDef iobase_methods[] = {
};
static PyGetSetDef iobase_getset[] = {
+ {"__dict__", iobase_get_dict, NULL, NULL},
{"closed", (getter)iobase_closed_get, NULL, NULL},
{NULL}
};