diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-01-03 02:38:38 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-01-03 02:38:38 (GMT) |
commit | fd53a5a01150de79cfb1673e89711c6cd6258ea2 (patch) | |
tree | d3db45cd6b5a5e403a9b62e7a47a035e292d9ff8 | |
parent | 18aa4477d37b8ead78f5f6c36c5da8b8ac593091 (diff) | |
parent | 6f84659e5e1dadcf12d1eb54fcd42ab6c42ac420 (diff) | |
download | cpython-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.
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Modules/_io/fileio.c | 13 |
2 files changed, 13 insertions, 2 deletions
@@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1? Core and Builtins ----------------- +- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB. + - Issue #16761: Calling int() with base argument only now raises TypeError. - Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py 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; |