Repository navigation
Fix 'python -m snappy -d' (cannot unpack non-iterable function object) - #155
Open
cristianchiriac wants to merge 2 commits into
Open
cristianchiriac wants to merge 2 commits into
cristianchiriac wants to merge 2 commits into
Conversation
get_decompress_function() returns a single function since d882cce, but the command line still unpacked a (function, chunk) tuple from it, so every decompression failed with "cannot unpack non-iterable function object". Use the returned function directly and rewind the input after guessing the format, as the format tests do. Fixes intake#153
Member
|
I believe this is the same as #154 |
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 #153.
Since d882cce,
get_decompress_function()returns only the decompress function.__main__.pystill unpacksmethod, read_chunkfrom it, so everypython -m snappy -d ...fails withTypeError: cannot unpack non-iterable function object. This happens with-t framingas well as with the defaultauto.The change:
start_chunk.-t auto, rewind the input after the format check. Guessing the format reads from the file (the framing check consumes the stream header, and the raw check seeks to the end), so the decompressor should start from the beginning.test_formats.pydoes the same withcompressed_stream.seek(0).I added
TestCommandLinetotest_formats.py. It compresses a file withpython -m snappy -c, then decompresses it with each CLI format (framing,auto) and compares the result with the original. Without the fix both subtests fail with the error above. With it,pytest test_formats.py test_snappy.pypasses (23 tests, Python 3.12).Note: CI currently runs only
test_snappy.py, so this test (and the existing format tests) only run locally unless the workflow is extended. I can add that here if you'd like.