summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-01-03 02:33:21 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-01-03 02:33:21 (GMT)
commit23a32ba0e5afcee7184408cf9415f038e864df96 (patch)
tree37881c23ca69420d82f4c912fbee77766faec712 /Modules
parent049a378cd7e2ec097715eb08d420b7fe3cd6b49a (diff)
downloadcpython-23a32ba0e5afcee7184408cf9415f038e864df96.zip
cpython-23a32ba0e5afcee7184408cf9415f038e864df96.tar.gz
cpython-23a32ba0e5afcee7184408cf9415f038e864df96.tar.bz2
Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/fileio.c13
1 files changed, 11 insertions, 2 deletions
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 @@ fileio_readall(fileio *self)
{
PyObject *result;
Py_ssize_t total = 0;
- int n;
+ Py_ssize_t n;
if (self->fd < 0)
return err_closed();
@@ -563,9 +563,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;