Repository navigation
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.
Summary
Support the optional
sizeargument onAbstractBufferedFile.readline, following the IOBase contract.The current signature rejects every positional size with
TypeError. This also breaks an existing standard-library consumer:http.client.parse_headers()callsfp.readline(_MAXLINE + 1). A regression test exercises that parser against anAbstractBufferedFilebacked byMemoryFileSystem, without network access.Positive sizes now bound the returned bytes, stopping at a newline or EOF and preserving any unread bytes after the newline. No-argument, negative and
Nonecalls keep the existingreaduntilpath. Zero-sized calls retain the existing closed-file checks. Invalid non-integer sizes are rejected before consuming data.Tests compare returned bytes and file positions with
io.BytesIOacross three cache types, empty content, line boundaries, repeated calls and seeking. A changelog entry is included. This does not changereadlines(hint)or backend-specific overrides.Validation
CPython 3.12.14, macOS, against upstream
685f62e:test_spec.py: 466 passed, 66 skipped, 1 xfailed (original baseline: 382 passed, 66 skipped, 1 xfailed).Full optional/cloud/Docker/downstream tests and other Python/OS environments were not run. This is a reproducible API compatibility fix, not a claim of a production incident or measured performance improvement.