Skip to content

snappy.uncompress and snappy.compress are not compatible with python -m snappy -c/d #28

@johnrfrank

Description

@johnrfrank

It appears that the module-level functions snappy.compress and snappy.uncompress have bitrotted and fallen behind the new framed version produced/consumed by the command-line interface.

Is the framed version adopted enough that those should be made consistent? Regardless, having this inconsistency seems like the wrong thing to do.

$ echo 'hello' | python -m snappy -c > hello.sz
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56) [GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import snappy
snappy.uncompress(open('hello.sz').read())
Traceback (most recent call last):
File "", line 1, in
snappy.UncompressError: Error while decompressing: invalid input

open('hello.sz').read()
'\xff\x06\x00\x00sNaPpY\x01\n\x00\x00SU\xffShello\n'
d = open('hello.sz').read()
snappy.uncompress(d)
Traceback (most recent call last):
File "", line 1, in
snappy.UncompressError: Error while decompressing: invalid input

snappy.compress('hello\n')
'\x06\x14hello\n'

from cStringIO import StringIO

fh = StringIO()
snappy.stream_decompress(StringIO(d), fh)
fh.getvalue()
'hello\n'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions