-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
Update os.pread to accept the length type as size_t #82446
Comments
I've found this comments. Line 8830 in 279f446
I don't know when this comment was created. How about updating this argument to be size_t and remove the TODO comment? |
Length should be Py_ssize_t. Python does not support creating bytes objects larger than PY_SSIZE_T_MAX. |
Oh okay! |
I think it is okay. Just check that all platforms which support pread() (Linux, *BSD, macOS) pass the length as size_t instead of int. Windows does not always support length larger than 2 KiB, but it does not support pread() either. |
Linux: http://man7.org/linux/man-pages/man2/pread.2.html All of them pass the length as size_t instead of int. |
Thank you @serhiy.storchaka and Kyle Stanley for the code review and approve. This issue is now solved. |
Python 3.7 and 3.8 also have os.pread(). Why not also fixing these branches? -- os.pwrite() uses Py_buffer for its argument and supports size_t size. os.preadv() and os.pwritev() use internally the C structure "struct iovec" which uses size_t for its iov_len field. |
Because this looks rather as a new feature than a bug fix. We don't add new features in maintained versions. Always there is a risk of introducing a regression. We don't know what bugs are contained in 64-bit size support on different platforms. I would not be surprised if for example some old macOS versions accept size_t, but work correctly only with the 32-bit size. |
Oh ok. That's fair. I close the issue. The workaround is to use os.preadv() or other functions which accept size_t. |
Or call pread() multiple times and concatenate results. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: