changeset: 71225:e8646f120330 parent: 71222:e38bb637328c parent: 71224:7acdf9f5eb31 user: Victor Stinner date: Tue Jul 05 11:34:18 2011 +0200 files: Misc/NEWS Modules/_io/fileio.c description: (merge 3.2) Issue #9611, #9015: FileIO.read() clamps the length to INT_MAX on Windows. diff -r e38bb637328c -r e8646f120330 Misc/NEWS --- a/Misc/NEWS Mon Jul 04 22:28:00 2011 -0500 +++ b/Misc/NEWS Tue Jul 05 11:34:18 2011 +0200 @@ -10,6 +10,8 @@ Core and Builtins ----------------- +- Issue #9611, #9015: FileIO.read() clamps the length to INT_MAX on Windows. + - Issue #9642: Uniformize the tests on the availability of the mbcs codec, add a new HAVE_MBCS define. @@ -1327,7 +1329,7 @@ (length bigger than 2^31-1 bytes). - Issue #9015, #9611: FileIO.readinto(), FileIO.write(), os.write() and - stdprinter.write() clamp the length to 2^31-1 on Windows. + stdprinter.write() clamp the length to INT_MAX on Windows. - Issue #8278: On Windows and with a NTFS filesystem, os.stat() and os.utime() can now handle dates after 2038. diff -r e38bb637328c -r e8646f120330 Modules/_io/fileio.c --- a/Modules/_io/fileio.c Mon Jul 04 22:28:00 2011 -0500 +++ b/Modules/_io/fileio.c Tue Jul 05 11:34:18 2011 +0200 @@ -687,6 +687,10 @@ return fileio_readall(self); } +#if defined(MS_WIN64) || defined(MS_WINDOWS) + if (size > INT_MAX) + size = INT_MAX; +#endif bytes = PyBytes_FromStringAndSize(NULL, size); if (bytes == NULL) return NULL; @@ -695,7 +699,11 @@ if (_PyVerify_fd(self->fd)) { Py_BEGIN_ALLOW_THREADS errno = 0; +#if defined(MS_WIN64) || defined(MS_WINDOWS) + n = read(self->fd, ptr, (int)size); +#else n = read(self->fd, ptr, size); +#endif Py_END_ALLOW_THREADS } else n = -1;