[issue7865] io close() swallowing exceptions

Pascal Chambon report at bugs.python.org
Sat Feb 6 13:27:08 CET 2010


New submission from Pascal Chambon <chambon.pascal at gmail.com>:

The current semantic of io streams is to swallow IOErrors on close(), eg. in _pyio from the trunk, we have each time constructs like:
try:
     self.flush()
except IOError:
     pass  # If flush() fails, just give up

and in C files :
        /* If flush() fails, just give up */
        if (PyErr_ExceptionMatches(PyExc_IOError))
            PyErr_Clear();

I'd rather advocate letting exceptions flow, as users have the right to know if their io operations lost bytes.
Below is a test case for these swallowed exceptions.


PS : issues like http://bugs.python.org/issue7640 are actually much more crucial, so we shall let them higher priority

----------
components: IO
files: test_error_close.py
messages: 98940
nosy: pakal
severity: normal
status: open
title: io close() swallowing exceptions
versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2
Added file: http://bugs.python.org/file16147/test_error_close.py

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7865>
_______________________________________


More information about the Python-bugs-list mailing list