Repository navigation
fix: preserve memoryview bytes in sandbox streaming uploads - #146
Draft
Kayvan-Zahiri wants to merge 1 commit into
Draft
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
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.
The sync and async sandbox
files.upload_streamhelpers treat amemoryviewas an iterable of chunks. Iterating a view yields integers, andbytes(integer)creates that many NUL bytes rather than encoding the original byte. For example, a view ofb"abc"produces 294 NUL bytes rather than three bytes of file data. This also mishandles sliced, non-contiguous, and wider-element views.Handle memoryview alongside bytes and bytearray before the iterable branch. Converting the whole view to bytes preserves its selected data and does not release the caller’s view. Document the supported bytes-like input on both public upload methods; existing readable-file and chunk-iterator paths stay unchanged.
Eighteen public-method regression/control cases consume the actual generated upload stream through recording runtime transports. They cover ordinary, sliced, strided, wide-element, and empty views, plus bytes, bytearray, file, and chunk-iterator controls, across sync and async APIs. Before:8 failed,10 passed. After:18 passed. The full non-E2E suite reports1017 passed,4 skipped,1 failed. The sole failure,
test_fingerprint_format_is_stable_across_python_versions, also fails on the original unmodified source in this macOS/Python3.12 environment; no fingerprint code was changed. Repository-wide Ruff lint, changed-file Ruff format, and git diff --check pass. No cloud sandbox or browser was launched.Developed with Codex assistance; reproduced and verified locally.