Title: `os.sendfile()` skips file data on macOS with headers and `count=0` · Issue #162378 · python/cpython · GitHub
Open Graph Title: `os.sendfile()` skips file data on macOS with headers and `count=0` · Issue #162378 · python/cpython
X Title: `os.sendfile()` skips file data on macOS with headers and `count=0` · Issue #162378 · python/cpython
Description: Bug report On macOS, passing a nonempty header to os.sendfile() with count=0 sends just the header. But the documented behavior is to send the file from offset to EOF: On macOS and FreeBSD, a value of 0 for count specifies to send until ...
Open Graph Description: Bug report On macOS, passing a nonempty header to os.sendfile() with count=0 sends just the header. But the documented behavior is to send the file from offset to EOF: On macOS and FreeBSD, a value...
X Description: Bug report On macOS, passing a nonempty header to os.sendfile() with count=0 sends just the header. But the documented behavior is to send the file from offset to EOF: On macOS and FreeBSD, a value...
Opengraph URL: https://github.com/python/cpython/issues/162378
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`os.sendfile()` skips file data on macOS with headers and `count=0`","articleBody":"### Bug report\n\nOn macOS, passing a nonempty header to `os.sendfile()` with `count=0` sends just the header.\n\nBut the documented behavior is to send the file from `offset` to EOF:\n\n> On macOS and FreeBSD, a value of 0 for count specifies to send until the end of in_fd is reached.\n\nhttps://docs.python.org/3/library/os.html#os.sendfile\n\n```python\nimport os\nimport socket\nimport tempfile\n\ntx, rx = socket.socketpair()\nwith tempfile.TemporaryFile() as f, tx, rx, rx.makefile(\"rb\") as reader:\n f.write(b\"abc\")\n f.flush()\n sent = os.sendfile(tx.fileno(), f.fileno(), 1, 0, headers=[b\"H\"])\n tx.shutdown(socket.SHUT_WR)\n print(sent, reader.read())\n```\n\n```bash\n2026-11-21T11:52:30.990254000+0100 maurycy@gimel /tmp/r % uv run --python 3.16 repro.py \n1 b'H'\n```\n\nit should be `3 b'Hbc'`\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162379\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/maurycy","@type":"Person","name":"maurycy"},"datePublished":"2026-11-21T10:54:20Z","url":"https://github.com/python/cpython/issues/162378"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:afbc0ddb-e0b7-7703-4d0e-59af0304151f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A6BA:3E418A:1299276:187BE51:6B01E943 |
| html-safe-nonce | e4432a4915d2d97fe7a0f9eb922a693ef31d160af834a4fa4591fe8e7573e5be |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNkJBOjNFNDE4QToxMjk5Mjc2OjE4N0JFNTE6NkIwMUU5NDMiLCJ2aXNpdG9yX2lkIjoiNTg5Njk1MDYzNzA0Mzc3MTcxNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | a75cb3f3a822dc0ea1d310362f3da405afe181436603e7e4a2cf75fb6af389f0 |
| hovercard-subject-tag | issue:6527884570 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/162378/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a6f71ffd5443b9452e7c11eec73ba9304389f7a13fa86d9d02da66ea45efaaea/python/cpython/issues/162378 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a6f71ffd5443b9452e7c11eec73ba9304389f7a13fa86d9d02da66ea45efaaea/python/cpython/issues/162378 |
| og:image:alt | Bug report On macOS, passing a nonempty header to os.sendfile() with count=0 sends just the header. But the documented behavior is to send the file from offset to EOF: On macOS and FreeBSD, a value... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | maurycy |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width