mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +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:
commit
b619bb27ed
3 changed files with 24 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue