Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,19 @@ PyDoc_STRVAR(iobase_doc,
"with open('spam.txt', 'r') as fp:\n"
" fp.write('Spam and eggs!')\n");

/* Use this macro whenever you want to check the internal `closed` status

/* Internal methods */

/* Use this function whenever you want to check the internal `closed` status
of the IOBase object rather than the virtual `closed` attribute as returned
by whatever subclass. */

static int
iobase_is_closed(PyObject *self)
{
return PyObject_HasAttrWithError(self, &_Py_ID(__IOBase_closed));
}

/* Internal methods */
static PyObject *
iobase_unsupported(_PyIO_State *state, const char *message)
{
Expand Down Expand Up @@ -145,14 +152,6 @@ _io__IOBase_truncate_impl(PyObject *self, PyTypeObject *cls,
return iobase_unsupported(state, "truncate");
}

static int
iobase_is_closed(PyObject *self)
{
/* This gets the derived attribute, which is *not* __IOBase_closed
in most cases! */
return PyObject_HasAttrWithError(self, &_Py_ID(__IOBase_closed));
}

/* Flush and close methods */

/*[clinic input]
Expand Down