mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
0f11a88622
commit
74a8b6ea7e
5 changed files with 33 additions and 26 deletions
|
|
@ -81,6 +81,19 @@ PyAPI_FUNC(int) _Py_EncodeLocaleEx(
|
|||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(__APPLE__)
|
||||
/* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
|
||||
On macOS 10.13, read() and write() with more than INT_MAX bytes
|
||||
fail with EINVAL (bpo-24658). */
|
||||
# define _PY_READ_MAX INT_MAX
|
||||
# define _PY_WRITE_MAX INT_MAX
|
||||
#else
|
||||
/* write() should truncate the input to PY_SSIZE_T_MAX bytes,
|
||||
but it's safer to do it ourself to have a portable behaviour */
|
||||
# define _PY_READ_MAX PY_SSIZE_T_MAX
|
||||
# define _PY_WRITE_MAX PY_SSIZE_T_MAX
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
struct _Py_stat_struct {
|
||||
unsigned long st_dev;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue