diff options
author | Charles-François Natali <neologix@free.fr> | 2011-10-05 17:55:56 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-10-05 17:55:56 (GMT) |
commit | b619bb27edba24c9c1ca08b682e08afd33e9ea0f (patch) | |
tree | 658c477f2d04e11d99fd7a9b67ac6f2b61f3dc88 /Modules/_io/bufferedio.c | |
parent | bb10a1f7597e3976eda0797b23f5aece3b2ff248 (diff) | |
parent | 42c28cdd1dbebbf241c1828ffceabf7978ddf566 (diff) | |
download | cpython-b619bb27edba24c9c1ca08b682e08afd33e9ea0f.zip cpython-b619bb27edba24c9c1ca08b682e08afd33e9ea0f.tar.gz cpython-b619bb27edba24c9c1ca08b682e08afd33e9ea0f.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/_io/bufferedio.c')
-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 b8043d4..86f7412 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -2307,6 +2307,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); } |