summaryrefslogtreecommitdiffstats
path: root/Modules/_io
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)
commitc44057dfbdb4e4f651e7cc4761aa63b7e8d128c3 (patch)
tree9ad4bcde8cb65c43dd6096aa428027400ba6d9e4 /Modules/_io
parent549d465fe2fe5ec85ed51cf7f7bf7f5b3d91e59b (diff)
downloadcpython-c44057dfbdb4e4f651e7cc4761aa63b7e8d128c3.zip
cpython-c44057dfbdb4e4f651e7cc4761aa63b7e8d128c3.tar.gz
cpython-c44057dfbdb4e4f651e7cc4761aa63b7e8d128c3.tar.bz2
Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB
Diffstat (limited to 'Modules/_io')
-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 605ad51..8ea7c58 100644
--- a/Modules/_io/fileio.c
+++ b/Modules/_io/fileio.c
@@ -558,7 +558,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();
@@ -591,9 +591,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;