diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-01-03 02:37:47 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-01-03 02:37:47 (GMT) |
commit | 6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420 (patch) | |
tree | a58bb3b131a54c4696f4e1f61d19aa28a0d72c7b /Modules | |
parent | 269b3ce40065afa3328953ec42657184da22f96b (diff) | |
parent | c44057dfbdb4e4f651e7cc4761aa63b7e8d128c3 (diff) | |
download | cpython-6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420.zip cpython-6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420.tar.gz cpython-6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420.tar.bz2 |
(Merge 3.2) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/fileio.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 6e0bbee..ca25209 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -607,7 +607,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) @@ -656,9 +656,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; |