mirror of
https://github.com/python/cpython.git
synced 2025-07-25 12:14:38 +00:00
Issue #19437: Fix _io._IOBase.close(), handle _PyObject_SetAttrId() failure
This commit is contained in:
parent
50abf2294e
commit
aa5bbfaa77
1 changed files with 8 additions and 3 deletions
|
@ -186,11 +186,16 @@ iobase_close(PyObject *self, PyObject *args)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
|
res = PyObject_CallMethodObjArgs(self, _PyIO_str_flush, NULL);
|
||||||
_PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True);
|
|
||||||
if (res == NULL) {
|
if (_PyObject_SetAttrId(self, &PyId___IOBase_closed, Py_True) < 0) {
|
||||||
|
Py_XDECREF(res);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Py_XDECREF(res);
|
|
||||||
|
if (res == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
Py_DECREF(res);
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue