mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
(Merge 3.3) Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
This commit is contained in:
commit
fd53a5a011
2 changed files with 13 additions and 2 deletions
|
@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
|
||||||
Core and Builtins
|
Core and Builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- Issue #16367: Fix FileIO.readall() on Windows for files larger than 2 GB.
|
||||||
|
|
||||||
- Issue #16761: Calling int() with base argument only now raises TypeError.
|
- Issue #16761: Calling int() with base argument only now raises TypeError.
|
||||||
|
|
||||||
- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py
|
- Issue #16759: Support the full DWORD (unsigned long) range in Reg2Py
|
||||||
|
|
|
@ -602,7 +602,7 @@ fileio_readall(fileio *self)
|
||||||
#endif
|
#endif
|
||||||
PyObject *result;
|
PyObject *result;
|
||||||
Py_ssize_t total = 0;
|
Py_ssize_t total = 0;
|
||||||
int n;
|
Py_ssize_t n;
|
||||||
size_t newsize;
|
size_t newsize;
|
||||||
|
|
||||||
if (self->fd < 0)
|
if (self->fd < 0)
|
||||||
|
@ -651,9 +651,18 @@ fileio_readall(fileio *self)
|
||||||
}
|
}
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
n = newsize - total;
|
||||||
|
#if defined(MS_WIN64) || defined(MS_WINDOWS)
|
||||||
|
if (n > INT_MAX)
|
||||||
|
n = INT_MAX;
|
||||||
n = read(self->fd,
|
n = read(self->fd,
|
||||||
PyBytes_AS_STRING(result) + total,
|
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
|
Py_END_ALLOW_THREADS
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue