Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

inaccurate block size in socket._sendfile_use_sendfile #112341

Closed as not planned
Closed as not planned
Labels
stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error
@aisk

Description

@aisk

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:

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

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp