mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
Fixes Issue #12268 for the io module - File readline, readlines and
read or readall methods no longer lose data when an underlying read system call is interrupted within an io module object. IOError is no longer raised due to a read system call returning EINTR from within these methods. This is a backport of changeset 781b95159954 from 3.2. The earlier 2.7 changeset 67dc99a989cd already fixed this for the builtin python 2.x file object.
This commit is contained in:
parent
2aa5afab4e
commit
99716166b1
7 changed files with 293 additions and 8 deletions
|
|
@ -1518,8 +1518,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) {
|
||||
|
|
@ -1678,8 +1684,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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue