mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
add a __dict__ descr for IOBase (closes #12878)
This commit is contained in:
parent
7335e6f3e8
commit
f6f3a35447
3 changed files with 27 additions and 0 deletions
|
@ -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}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue