Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c
index 5411665..7fe2454 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -530,7 +530,7 @@
 {
     PyObject *result;
     Py_ssize_t total = 0;
-    int n;
+    Py_ssize_t n;
 
     if (self->fd < 0)
         return err_closed();
@@ -563,9 +563,18 @@
         }
         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,
-                 newsize - total);
+                 (int)n);
+#else
+        n = read(self->fd,
+                 PyBytes_AS_STRING(result) + total,
+                 n);
+#endif
         Py_END_ALLOW_THREADS
         if (n == 0)
             break;