python-snappy icon indicating copy to clipboard operation
python-snappy copied to clipboard

`guess_format_by_header` is buggy

Open seperman opened this issue 1 year ago • 0 comments

Hello, Snappy Python can't guess the format for its own compressed output:

import io
import snappy
from snappy import snappy_formats

values = b"What is going on?\n"

def snappy_compress_file_obj(in_file, out_file):
    in_file.seek(0)
    result = snappy.compress(in_file.read())
    out_file.write(result)
    out_file.seek(0)


def main():
    file_obj = io.BytesIO(values)
    output_file_obj = io.BytesIO()
    snappy_compress_file_obj(file_obj, output_file_obj)
    snappy_formats.guess_format_by_header(fin=output_file_obj)


if __name__ == '__main__':
    main()

This will throw:

snappy.snappy.UncompressError: Can't detect archive format

Python version: 3.12.3 python-snappy==0.7.1 Ubuntu 20.04 LTS

seperman avatar May 18 '24 06:05 seperman