sergey-dryabzhinsky / python-zstd

Simple python bindings to Yann Collet ZSTD compression library
BSD 2-Clause "Simplified" License
165 stars 27 forks source link

Fix issues compressing an empty bytestring #81

Closed nepeat closed 2 years ago

nepeat commented 2 years ago

Test included and refactoring included. This fixes #80

Before

>>> zstd.compress(b"")
b"\xe4As\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'str' object cannot be interpreted as an integer"
>>> zstd.compress(b"")
b"\xe4\x80s\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'ModuleSpec' object has no attribute '_initializ"

After

>>> zstd.compress(b"")
b'(\xb5/\xfd \x00\x01\x00\x00'
sergey-dryabzhinsky commented 2 years ago

Thank you!