Repository navigation
Fix empty multipart chunk boundaries - #405
Draft
lexingtonhibiki wants to merge 1 commit into
Draft
lexingtonhibiki wants to merge 1 commit into
lexingtonhibiki 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.
Problem
Related to #218. The historical read-all exception is already avoided, but empty encoders still produce a malformed closing boundary when read in small chunks.
For
MultipartEncoder({}, boundary='boundary'),.lenis 14. Repeatedread(1)currently emitsb'--boundary\r\n--\r\n'(16 bytes), rather thanb'--boundary--\r\n'. The initial boundary's CRLF can be consumed before the lazy closing-boundary rewrite occurs. Empty lists and partial-read-then-read-all have the same issue.Change
Finalize the empty encoder's closing boundary during initialization, before any bytes can be consumed. Nonempty encoders keep the existing path. Add 22 parametrized regression cases for empty mappings/lists, chunk sizes and mixed read patterns; update AUTHORS and HISTORY.
Validation
Python 3.12, local offline execution with socket, DNS and subprocess guards (zero attempted operations):
These full-suite counts use
pytest tests -o addopts='' -q -W ignore::DeprecationWarningthrough the offline guard runner. With warnings treated as errors instead, the fixed tree still has 28 preexisting deprecation failures (baseline with new tests: 42 failures, including the 14 regressions). This change does not address those unrelated failures.An independent AI review/probe covered 184 read sequences: baseline 18 failures, fixed zero, including nonempty controls, read(0), partial/read-all and repeated EOF. A separate 12-case monitor probe checked callbacks, bytes_read and lengths for empty and nonempty bodies. Production flake8 and git diff --check pass.
AI-assisted implementation and independent AI review; no human review is claimed. Older Python runtimes and live HTTP were not exercised locally. Kept as a draft for maintainer review.