diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/bufferedio.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 73f924e..1b81647 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2179,6 +2179,11 @@ bufferedrwpair_isatty(rwpair *self, PyObject *args) static PyObject * bufferedrwpair_closed_get(rwpair *self, void *context) { + if (self->writer == NULL) { + PyErr_SetString(PyExc_RuntimeError, + "the BufferedRWPair object is being garbage-collected"); + return NULL; + } return PyObject_GetAttr((PyObject *) self->writer, _PyIO_str_closed); } |