-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-24658: Fix read/write on file with a size greater than 2GB on OSX #1705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f810129
1b7d412
3c447d8
b5b2754
1130c44
207f00f
7064bd5
84b09f9
a8c0aa1
3d7fe38
bb3e082
fc08e60
17d0d04
468dbbe
4140591
86fa808
83dd759
15e176d
d4ec7ec
a21bfcb
4382256
a696899
b8d1f24
3e887f5
530799a
4c9a61f
04ccd69
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
On macOS, fix reading from and writing into a file with a size larger than 2 GiB. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,11 +791,9 @@ _io_FileIO_read_impl(fileio *self, Py_ssize_t size) | |
if (size < 0) | ||
return _io_FileIO_readall_impl(self); | ||
|
||
#ifdef MS_WINDOWS | ||
/* On Windows, the count parameter of read() is an int */ | ||
if (size > INT_MAX) | ||
size = INT_MAX; | ||
#endif | ||
if (size > _PY_READ_MAX) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure that it's ok to use this if on OS other than macOS and Windows, since size type is ssize_t. I expect "condition is always false" warnings on many recent compilers. I would prefer to keep an #ifdef. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note for myself: the issue has been fixed |
||
size = _PY_READ_MAX; | ||
} | ||
|
||
bytes = PyBytes_FromStringAndSize(NULL, size); | ||
if (bytes == NULL) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just
size
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed