gh-112341: Specify the exact file size if offset is non zero in socket.sendfile#112342
gh-112341: Specify the exact file size if offset is non zero in socket.sendfile#112342aisk wants to merge 4 commits intopython:mainfrom
socket.sendfile#112342Conversation
socket.sendfile
|
Is there an easy way to add tests for this? |
|
Thanks for the review, test case added. |
|
How does this relate to |
|
The problem this PR want to resolve is that, if we have a file with size 42, and want to send it to a socket from the start Because we do not specify the count parameter, The current codes in main branch missed the Then Modern systems which CPython supports with But I've tried to implement the So I think this is a bug and we should fix it. But, the is not the end of this story. I found that the And then the change in this PR is not a must to have. But I still feels like it's a bug, so we should fix it 😂. |
|
Thanks, @aisk, makes sense to me! cc. @serhiy-storchaka if he want's to take a look. I'm aiming for landing this in a couple of days. |
|
Could you try to compose a short NEWS entry for this? I'm unsure if we really need one; this feels like an implementation detail. |
| return 0 # empty file | ||
| # Truncate to 1GiB to avoid OverflowError, see bpo-38319. | ||
| blocksize = min(count or fsize, 2 ** 30) | ||
| blocksize = min(count or fsize - offset, 2 ** 30) |
There was a problem hiding this comment.
What if offset >= fsize?
Please add tests for offset == fsize and offset > fsize.
|
There are some discussions on the original issue #112341. I think this should not be treated as a bug, so I'm closing this. If anyone wants to discuss it further, we can reopen it. Still appreciate the review! |
I think this is a minor fix, so the news entry is not needed.