diff options
author | Charles-François Natali <neologix@free.fr> | 2011-10-06 17:09:45 (GMT) |
---|---|---|
committer | Charles-François Natali <neologix@free.fr> | 2011-10-06 17:09:45 (GMT) |
commit | 9ffcbf71a52bcca74022fb58f56b145ff6af7f97 (patch) | |
tree | e2ec1997f7ec17b0abc63e0a96abf14386497042 /Modules | |
parent | e954ecb9ba35d3d075bae423c964fa8a6771968c (diff) | |
download | cpython-9ffcbf71a52bcca74022fb58f56b145ff6af7f97.zip cpython-9ffcbf71a52bcca74022fb58f56b145ff6af7f97.tar.gz cpython-9ffcbf71a52bcca74022fb58f56b145ff6af7f97.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 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); } |