diff options
author | Gregory P. Smith <greg@krypto.org> | 2012-06-24 06:55:39 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2012-06-24 06:55:39 (GMT) |
commit | 5135992164f4c0df8d18d3b486431b28214db16b (patch) | |
tree | 7bc3060d22ad740bf2bf795caae1c6a46232f6e7 /Modules/_io/textio.c | |
parent | 8150492f11f17e2a09f7deb7af706536bc326c98 (diff) | |
download | cpython-5135992164f4c0df8d18d3b486431b28214db16b.zip cpython-5135992164f4c0df8d18d3b486431b28214db16b.tar.gz cpython-5135992164f4c0df8d18d3b486431b28214db16b.tar.bz2 |
Fixes issue #12268: File readline, readlines and read() or readall() methods
no longer lose data when an underlying read system call is interrupted.
IOError is no longer raised due to a read system call returning EINTR
from within these methods.
Diffstat (limited to 'Modules/_io/textio.c')
-rw-r--r-- | Modules/_io/textio.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index baf0a97..d86a1c7 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -1541,8 +1541,14 @@ textiowrapper_read(textio *self, PyObject *args) /* Keep reading chunks until we have n characters to return */ while (remaining > 0) { res = textiowrapper_read_chunk(self); - if (res < 0) + if (res < 0) { + /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() + when EINTR occurs so we needn't do it ourselves. */ + if (_PyIO_trap_eintr()) { + continue; + } goto fail; + } if (res == 0) /* EOF */ break; if (chunks == NULL) { @@ -1701,8 +1707,14 @@ _textiowrapper_readline(textio *self, Py_ssize_t limit) while (!self->decoded_chars || !PyUnicode_GET_SIZE(self->decoded_chars)) { res = textiowrapper_read_chunk(self); - if (res < 0) + if (res < 0) { + /* NOTE: PyErr_SetFromErrno() calls PyErr_CheckSignals() + when EINTR occurs so we needn't do it ourselves. */ + if (_PyIO_trap_eintr()) { + continue; + } goto error; + } if (res == 0) break; } |