镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix 'python -m snappy -d' (cannot unpack non-iterable function object) - #155

Open
cristianchiriac wants to merge 2 commits into
intake:masterfrom
cristianchiriac:fix-cli-decompress
Open

cristianchiriac wants to merge 2 commits into
intake:masterfrom
cristianchiriac:fix-cli-decompress

Conversation

@cristianchiriac

Copy link
Copy Markdown

Fixes #153.

Since d882cce, get_decompress_function() returns only the decompress function. __main__.py still unpacks method, read_chunk from it, so every python -m snappy -d ... fails with TypeError: cannot unpack non-iterable function object. This happens with -t framing as well as with the default auto.

The change:

  • Use the returned function directly. It is called without start_chunk.
  • With -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.py does the same with compressed_stream.seek(0).

I added TestCommandLine to test_formats.py. It compresses a file with python -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.py passes (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.

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
@martindurant

Copy link
Copy Markdown
Member

I believe this is the same as #154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python -m snappy -d raises TypeError: cannot unpack non-iterable function object

2 participants