summaryrefslogtreecommitdiffstats
path: root/Modules/_io/fileio.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-01-03 02:38:38 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-01-03 02:38:38 (GMT)
commitfd53a5a01150de79cfb1673e89711c6cd6258ea2 (patch)
treed3db45cd6b5a5e403a9b62e7a47a035e292d9ff8 /Modules/_io/fileio.c
parent18aa4477d37b8ead78f5f6c36c5da8b8ac593091 (diff)
parent6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420 (diff)
downloadcpython-fd53a5a01150de79cfb1673e89711c6cd6258ea2.zip
cpython-fd53a5a01150de79cfb1673e89711c6cd6258ea2.tar.gz
cpython-fd53a5a01150de79cfb1673e89711c6cd6258ea2.tar.bz2
(Merge 3.3) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
Diffstat (limited to 'Modules/_io/fileio.c')
-rw-r--r--Modules/_io/fileio.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index beacd9f..34425b7 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -602,7 +602,7 @@ fileio_readall(fileio *self)
#endif
PyObject *result;
Py_ssize_t total = 0;
- int n;
+ Py_ssize_t n;
size_t newsize;
if (self->fd < 0)
@@ -651,9 +651,18 @@ fileio_readall(fileio *self)
}
Py_BEGIN_ALLOW_THREADS
errno = 0;
+ n = newsize - total;
+#if defined(MS_WIN64) || defined(MS_WINDOWS)
+ if (n > INT_MAX)
+ n = INT_MAX;
+ n = read(self->fd,
+ PyBytes_AS_STRING(result) + total,
+ (int)n);
+#else
n = read(self->fd,
PyBytes_AS_STRING(result) + total,
- newsize - total);
+ n);
+#endif
Py_END_ALLOW_THREADS
if (n == 0)
break;