bpo-33871: Fix os.sendfile(), os.writev(), os.readv(), etc. by serhiy-storchaka · Pull Request #7931 · python/cpython (original) (raw)
I've checked the SDK headers to be sure, and off_t is indeed always 64-bit (off_t is a typedef for __darwin_off_t, and that in turn is a typedef for __int64_t).
The manpage for sendfile(2) doesn't mention this, but the one for writev(2) says:
[EINVAL] The sum of the iov_len values in the iov array overflows a 32-bit integer.
Furthermore we have had problems with write(2) in the past when writing more than INT_MAX bytes at a time (see the implementation of _Py_write_impl). I think it is therefore better to limit the maximum size to INT_MAX, unless we explicitly test that sendfile can send more than INT_MAX bytes in one go.
BTW. Instead of OFF_T_MAX you could use OFF_MAX here, that should be defined to the maximum value of off_t.