diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-10 23:32:12 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-04-10 23:32:12 (GMT) |
commit | bba8f2d10a6d513650a05b821d1c69f86d29cdef (patch) | |
tree | 0d6ef2e5a7e942c10b17007547b687a1e20bdd45 /Modules/_io | |
parent | 16e026cc943460b83a08c058ba4e87c5abf36215 (diff) | |
download | cpython-bba8f2d10a6d513650a05b821d1c69f86d29cdef.zip cpython-bba8f2d10a6d513650a05b821d1c69f86d29cdef.tar.gz cpython-bba8f2d10a6d513650a05b821d1c69f86d29cdef.tar.bz2 |
Revert temporary commit in r79937
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/fileio.c | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 8f174a7..ec320f7 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -464,34 +464,6 @@ fileio_seekable(fileio *self) return PyBool_FromLong((long) self->seekable); } -static Py_ssize_t -internal_read(int fd, void *buf, size_t count) -{ - Py_ssize_t n; - - Py_BEGIN_ALLOW_THREADS - errno = 0; - n = read(fd, buf, count); -#ifdef EIO - /* Issue #5380: when reading past the end of a pipe created by - openpty(), EIO can be set. Make it an EOF instead, so that - the normal technique of testing for an empty string can be used. - */ - if (n == -1 && errno == EIO) { - if (isatty(fd)) { - n = 0; - errno = 0; - } - else { - /* isatty() set errno, restore its value */ - errno = EIO; - } - } -#endif - Py_END_ALLOW_THREADS - return n; -} - static PyObject * fileio_readinto(fileio *self, PyObject *args) { @@ -506,9 +478,12 @@ fileio_readinto(fileio *self, PyObject *args) if (!PyArg_ParseTuple(args, "w*", &pbuf)) return NULL; - if (_PyVerify_fd(self->fd)) - n = internal_read(self->fd, pbuf.buf, pbuf.len); - else + if (_PyVerify_fd(self->fd)) { + Py_BEGIN_ALLOW_THREADS + errno = 0; + n = read(self->fd, pbuf.buf, pbuf.len); + Py_END_ALLOW_THREADS + } else n = -1; PyBuffer_Release(&pbuf); if (n < 0) { @@ -585,9 +560,12 @@ fileio_readall(fileio *self) break; } } - n = internal_read(self->fd, - PyBytes_AS_STRING(result) + total, - newsize - total); + Py_BEGIN_ALLOW_THREADS + errno = 0; + n = read(self->fd, + PyBytes_AS_STRING(result) + total, + newsize - total); + Py_END_ALLOW_THREADS if (n == 0) break; if (n < 0) { @@ -639,9 +617,12 @@ fileio_read(fileio *self, PyObject *args) return NULL; ptr = PyBytes_AS_STRING(bytes); - if (_PyVerify_fd(self->fd)) - n = internal_read(self->fd, ptr, size); - else + if (_PyVerify_fd(self->fd)) { + Py_BEGIN_ALLOW_THREADS + errno = 0; + n = read(self->fd, ptr, size); + Py_END_ALLOW_THREADS + } else n = -1; if (n < 0) { |