Issue #7865: The close() method of :mod:`io` objects should not swallow
exceptions raised by the implicit flush(). Also ensure that calling
close() several times is supported. Patch by Pascal Chambon.
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index ba937ed..feee9be 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -440,11 +440,7 @@
res = PyObject_CallMethodObjArgs((PyObject *)self, _PyIO_str_flush, NULL);
ENTER_BUFFERED(self)
if (res == NULL) {
- /* If flush() fails, just give up */
- if (PyErr_ExceptionMatches(PyExc_IOError))
- PyErr_Clear();
- else
- goto end;
+ goto end;
}
Py_XDECREF(res);