Repository navigation
Keep IgzipDecompressor.needs_input set to False while output is left - #298
Merged
rhpvorderman merged 1 commit intoOct 27, 2026
Merged
Conversation
When the output buffer is full, isal_inflate keeps decoding into its own buffer, so it can read all of the input while output is left. needs_input was then True, and readers such as CPython's DecompressReader raised EOFError on valid data. Set needs_input only when the output buffer was not full, as CPython's LZMADecompressor does.
rhpvorderman
approved these changes
Oct 27, 2026
rhpvorderman
left a comment
Collaborator
There was a problem hiding this comment.
Excellent. Thanks. The igzip_lib decompressor was initially made for the python _GzipReader object, but has been superseded by the C _GzipReader.
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.
After
decompress(data, max_length)returnsmax_lengthbytes,needs_inputcan beTruealthough the nextdecompress(b"", max_length)call returns more data. The docstring ofdecompress()says the opposite:When the output buffer is full,
isal_inflate()keeps decoding into its own buffer, so it can read all of the input before the output is returned.decompress()setsneeds_inputwhenever no input is left, like CPython'sBZ2Decompressor, which it is based on.Readers that stop at the end of the file when
needs_inputisTruefail on valid data. CPython'sDecompressReader, whichbz2andlzmause for files, raisesEOFError: Compressed file ended before the end-of-stream marker was reached. It does so for 1,000 bytes of data read withread(100), and for 100,000 bytes read withread(8192).zlib._ZlibDecompressorreads the same streams.This PR sets
needs_inputonly when the output buffer was not full, as CPython'sLZMADecompressordoes. When the output buffer was full and no output is left, the nextdecompress()call returnsb""and setsneeds_input.The new test fails without the fix.
testDecompressorChunksMaxsizecould not catch this. Like the CPythontest_bz2test it comes from, it passes all but 64 bytes of the stream in the first call, which is more input than ISA-L reads while the output is full.Checklist