Repository navigation
Ignore empty object-stream messages in buffered byte receives - #1409
Merged
agronholm merged 6 commits intoOct 12, 2026
Merged
Conversation
00200200
marked this pull request as ready for review
October 11, 2026 14:18
agronholm
reviewed
Oct 11, 2026
agronholm
reviewed
Oct 11, 2026
agronholm
reviewed
Oct 11, 2026
Contributor
Author
|
All review suggestions are addressed. The remaining CI failure on head 3b14ae7 is the Python 3.15 asyncio job: test_aclose_waits_for_fd_release[asyncio-ipv4] fails rebinding a UDP port with Errno 98, followed by an unclosed-socket warning in test_create_connected_socket_bound_to_port[asyncio+eager-ipv6]. These failures are in unchanged socket tests; the buffered-stream regression tests pass. I could not rerun job 114523333291 through GitHub. Could you rerun the failed job before merge? I have not changed socket code or disabled tests. |
agronholm
reviewed
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NOTE Erasing or replacing the contents of this template will result in your pull
request being summarily closed without consideration!
Changes
No linked issue.
BufferedByteReceiveStream.receive()currently returnsb""when a wrappedObjectReceiveStream[bytes]supplies an empty message. Empty messages are validobjects, but
ByteReceiveStream.receive()documents that implementations shouldnot return empty bytes. For example, a memory object stream containing
b""followed by
b"abcd"makesreceive(2)returnb""instead ofb"ab".Empty messages followed by sender closure likewise produce empty reads before EOF.
Skip empty object-stream messages until data arrives or the underlying stream
raises
EndOfStream. Preserve the existing byte-stream path, maximum read size,and buffering of surplus data.
BufferedByteStreaminherits the same fix.The two regression tests use real memory object streams and both wrappers. They
cover consecutive empty messages, empties between data chunks, surplus buffering,
and empty messages followed by EOF. All 16 parametrized cases failed on the
unchanged implementation: either
b"" != b"ab"or a missingEndOfStream.Local validation on macOS, CPython 3.12.11, with asyncio, uvloop, eager asyncio,
and Trio (including the configured Blockbuster instrumentation):
python -m pytest tests/streams/ -q --tb=short: 404 passed.python -m pytest tests/test_to_process.py tests/test_subprocesses.py -q --tb=short:137 passed, 3 skipped (uvloop does not support the tested user/group/umask options).
pre-commit run --all-files: passed, including Ruff and mypy.The full repository test suite, other Python versions, and Windows/Linux were
not run locally. This contribution was implemented and validated with OpenAI
Codex; no human review is claimed. Open PRs were checked for overlapping work.
Checklist
If this is a user-facing code change, like a bugfix or a new feature, please ensure that
you've fulfilled the following conditions (where applicable):
tests/) which would fail without your patchdocs/), in case of behavior changes or newfeatures
changelog.d/).The existing byte-stream contract is unchanged; the class docstring now documents
empty-message handling. No file under
docs/was changed. The changelog fragment ischangelog.d/1409.fixed.rst.If this is a trivial change, like a typo fix or a code reformatting, then you can ignore
these instructions.
Updating the changelog
Add a news fragment file in the
changelog.d/directory, named<issue or PR number>.<type>.rst, where<type>is one of:breaking: backwards incompatible changesadded: new featureschanged: other user-visible changesfixed: bug fixesIf, say, your patch fixes issue #123, create
changelog.d/123.fixed.rstcontaining only a brief summary of the change, like this:
The issue link and the credit for your pull request are added automatically on release.
If there's no issue linked, name the file after your pull request instead by adding the
fragment after you've created the PR.