bpo-24658: Fix read/write greater than 2 GiB on macOS (GH-1705)
On macOS, fix reading from and writing into a file with a size larger than 2 GiB.
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index c0e43e0..44d51c9 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -791,11 +791,9 @@
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)