Repository navigation
Fix memoryview payload serialization and byte-length limits - #14019
Open
Vaishnavi220506 wants to merge 2 commits into
Open
Vaishnavi220506 wants to merge 2 commits into
Vaishnavi220506 wants to merge 2 commits into
Conversation
Automation signalsActivity patterns show signs of automation. Evidence
Last 5 PRs:
This is an automated analysis by AgentScan |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #14019 +/- ##
==========================================
- Coverage 99.10% 99.10% -0.01%
==========================================
Files 135 135
Lines 53551 53600 +49
Branches 2809 2811 +2
==========================================
+ Hits 53071 53118 +47
- Misses 362 363 +1
- Partials 118 119 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
Vaishnavi220506
marked this pull request as ready for review
October 13, 2026 04:54
Contributor
|
This was referenced Nov 9, 2026
This branch has not been deployed
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.
What do these changes do?
Fix
BytesPayloadserialization for memoryviews whose elements or dimensions are not individual bytes. Normalize contiguous views to a flat byte view without copying, and materialize non-contiguous or empty views as bytes.decode()andas_bytes()now work for all accepted buffer types.For example, writing
BytesPayload(memoryview(b"abcdefgh").cast("H"))with a length limit of 3 currently writes 6 bytes. A(2, 4)view writes all 8 bytes instead, and a scalar view raisesTypeError. All three now honor the limit in bytes. Callingdecode()on any memoryview previously raisedAttributeError.Regression tests cover typed, multidimensional, strided, scalar, and empty views; a mutable-buffer test checks that contiguous views remain live. HTTP round trips exercise both request uploads and response bodies.
Local validation
Base:
708528592b1a8fdfc1cbe0d81fe4417693f0bb5d. The regression run produced 17 failures and 27 passes before the production fix.Windows, CPython 3.14.3, pure Python:
All applicable
pre-commit run --files aiohttp/payload.py tests/test_payload.py tests/test_client_functional.py CONTRIBUTORS.txt CHANGES/70852859.bugfix.rsthooks passed in a Linux checkout of the same patch. The hook environments neededsetuptools<81for the repository'sflake8-requirementsplugin.The full suite and compiled extensions were not run.
mypy aiohttp/payload.pyon Linux with CPython 3.12.3 reports the same three errors on upstream and this patch, incompression_utils.pyandclient_reqrep.py; none are in the changed module.Are there changes in behavior for the user?
Byte limits apply to bytes regardless of a view's format or shape. Strided and scalar payloads can be transmitted, memoryviews can be decoded, and
as_bytes()returnsbytesfor bytearray and memoryview inputs as its return annotation specifies. Non-contiguous views are snapshotted at construction; contiguous views still reflect buffer mutations.Is it a substantial burden for the maintainers to support this?
No new dependencies or API parameters. Buffer normalization stays in the existing
BytesPayloadconstructor, so its consumers share the fix.Related issue number
N/A — found through local reproduction.
Checklist
as_bytes()docstring and added a news fragmentCONTRIBUTORS.txtCHANGES/folderDrafted with OpenAI Codex (GPT-6); reviewed by @Vaishnavi220506.