mirror of
https://github.com/python/cpython.git
synced 2025-07-24 19:54:21 +00:00
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.
This commit is contained in:
parent
1b7da519b0
commit
42c28cdd1d
3 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue