diff options
author | Charles-François Natali <neologix@free.fr> | 2011-10-05 17:53:43 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-10-05 17:53:43 (GMT) |
commit | 42c28cdd1dbebbf241c1828ffceabf7978ddf566 (patch) | |
tree | f0a0e094b0039c4092dc30090a85b8993a6d74fe /Modules | |
parent | 1b7da519b09d8885272d323af982d36675419075 (diff) | |
download | cpython-42c28cdd1dbebbf241c1828ffceabf7978ddf566.zip cpython-42c28cdd1dbebbf241c1828ffceabf7978ddf566.tar.gz cpython-42c28cdd1dbebbf241c1828ffceabf7978ddf566.tar.bz2 |
Issue #13070: Fix a crash when a TextIOWrapper caught in a reference cycle
would be finalized after the reference to its underlying BufferedRWPair's
writer got cleared by the GC.
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 bd1aae5..c979ac2 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2212,6 +2212,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); } |