Repository navigation
Conversation
SocketStream and FdStream treated send()/os.write() return values as element offsets into the memoryview. For contiguous views with itemsize > 1, a partial write skipped data and returned success early. Cast nonempty contiguous views to a 1-D bytes view before slicing. Fixes python-trio#3543.
for more information, see https://pre-commit.ci
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3545 +/- ##
====================================================
- Coverage 100.00000% 99.95896% -0.04104%
====================================================
Files 128 128
Lines 19474 19494 +20
Branches 1323 1326 +3
====================================================
+ Hits 19474 19486 +12
- Misses 0 7 +7
- Partials 0 1 +1
🚀 New features to boost your workflow:
|
Contributor
|
Same as the other PR, I'm not willing to guide an LLM step by step into contributing. I can do that myself! (and I don't really get why you'd want to special case contiguous memory views...?) |
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.
Summary
SocketStream.send_alland POSIXFdStream.send_allused byte counts fromsend()/os.write()as memoryview element offsets. For a contiguous view withitemsize > 1, a partial write could skip data and return successfully without sending the full buffer.Cast nonempty contiguous views to a one-dimensional bytes view before slicing so offsets and lengths stay in bytes.
Fixes #3543.
Test plan
memoryview(...).cast("H")over a pipetest_SocketStream_send_all/ pipe send tests still pass