Repository navigation
Fix stream reader readinto position accounting - #351
Open
CAOShurong wants to merge 1 commit into
Open
CAOShurong wants to merge 1 commit into
CAOShurong 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.
Fixes #295.
The C
readinto()andreadinto1()paths compress into a local output buffer,but at EOF they increment
bytesCompressedfromself->output.pos. This canleave
tell()unchanged or wrap the counter after earlier output. Use the localoutput.pos - oldPosinstead, without changing compression or buffer ownership.The regressions check cumulative emitted bytes after every call, bytes/stream
sources, small and multi-block inputs, mixed reads, guarded writable views,
repeated EOF and invalid/closed calls. They also verify decompression round trips.
The unchanged C backend fails two of the three new methods; CFFI passes them.
Validation on Windows x64, CPython 3.13.1, after building an sdist/wheel and
installing the wheel non-editably:
pytest --import-mode=importlib <checkout>/tests/test_compressor_stream_reader.py -q:22 passed on C and CFFI, twice each.
pytest --import-mode=importlib <checkout>/tests -q: C 251 passed/44 skipped;CFFI 227 passed/68 skipped, twice each. All 292 pre-existing test outcomes match
the unchanged baseline.
ZSTD_SLOW_TESTS=1, compression-reader fuzzing: 16 passed per backend(
--hypothesis-seed=295, default profile).ruff check ., changed-file format check, configured mypy (33 files), andgit diff --checkpassed. C extension built with warnings as errors.The setuptools
test_suite/tests_requirewarnings are unchanged from baseline.An empty bytes source stalled in the unchanged baseline and was excluded from
the additional API probe; an empty
BytesIOsource is covered by the regression.Rust, other platforms/Python versions, and the full CI fuzzing profile were not
run locally.