Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.1k
Description
Bug report
Bug description:
socket._sendfile_use_sendfile(self, file, offset=0, count=None)
intent to use the file size reamains from current position as block size, to a underlyingsendfile
syscall, when count is not specified.
But as the codes below shows, it will always use the whole file size as block size even if offset is non zero, so the blocksize is larger than actuall file bytes remains from offset:
Line 363 in89ddea4
blocksize=min(countorfsize,2**30) |
On modern platforms, if someone specified the count which is larger than the actual file size,sendfile
will accept it, and only sending the remaining data and returns the bytes which have been sent.
So the bug (if it is a bug) have no effect for now, and it's so minor, but I think we should fix it however. And if we want usingTransmitFile
as asendfile
implenentation on Windows, the inaccurate block size will leads to an error, which is mentioned in#102898 (comment), and the fix will be a must have.
CPython versions tested on:
3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch
Operating systems tested on:
macOS