Repository navigation
Support read_block with no delimiter and length=None - #2262
Merged
martindurant merged 5 commits intoOct 14, 2026
Merged
Conversation
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
| f.seek(offset) | ||
|
|
||
| # TODO: allow length to be None and read to the end of the file? | ||
| assert length is not None |
Member
There was a problem hiding this comment.
Non-test code should not contain asserts anyway (they can be stripped in bytecode) ...
| assert length is not None | ||
| b = f.read(length) | ||
| return b | ||
| return f.read() if length is None else f.read(length) |
Member
There was a problem hiding this comment.
Isn't this just f.read(length), since it accepts None and does the right thing?
Contributor
Author
There was a problem hiding this comment.
Yes, simplified to f.read(length) in 75a5878. Also resolved the changelog conflict with current master. Rechecked the final head: Windows utility/core tests 262 passed; Linux utility/spec/local/memory/core tests 932 passed (existing skips/xfail retained). Thanks!
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
Signed-off-by: Xucheng Zhou <aden1350@outlook.com>
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.
fsspec.utils.read_blockdocuments and annotateslength=Noneas reading through EOF. That works with a delimiter, but without one the function reachesassert length is not None:Use an unbounded
read()for None, retainingread(length)for finite lengths. Add real-file and BytesIO regressions for start/interior/EOF/past-EOF offsets, with zero and finite-length controls, and clarify the docstring type. Existing delimiter handling is unchanged.Validation against master
94afb3f6, Python 3.12:Distinct from #2256 (delimiter + split_before) and #2261 (filesystem-level negative lengths). AI-assisted and independently reproduced. These are scoped native tests, not cloud-service or full-CI qualification.