From 178d1c07778553bf66e09fe0bb13796be3fb9abf Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 17 Oct 2018 23:58:40 -0700 Subject: bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, fix reading from and writing into a file with a size larger than 2 GiB. (cherry picked from commit 74a8b6ea7e0a8508b13a1c75ec9b91febd8b5557) Co-authored-by: Stéphane Wirtel --- Modules/_io/fileio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'Modules/_io') diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index 0d5bf3b221..8bbe1ce367 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -791,11 +791,9 @@ _io_FileIO_read_impl(fileio *self, Py_ssize_t size) if (size < 0) return _io_FileIO_readall_impl(self); -#ifdef MS_WINDOWS - /* On Windows, the count parameter of read() is an int */ - if (size > INT_MAX) - size = INT_MAX; -#endif + if (size > _PY_READ_MAX) { + size = _PY_READ_MAX; + } bytes = PyBytes_FromStringAndSize(NULL, size); if (bytes == NULL) -- cgit v1.2.1