Skip to content

Commit bda6c24

Browse files
authored
Merge pull request #90 from pycompression/release_0.11.1
Release 0.11.1
2 parents 901133f + b96148d commit bda6c24

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 0.11.1
11+
------------------
12+
+ Fixed an issue which occurred rarely that caused IgzipDecompressor's
13+
unused_data to report back incorrectly. This caused checksum errors when
14+
reading gzip files. The issue was more likely to trigger in multi-member gzip
15+
files.
16+
1017
version 0.11.0
1118
------------------
1219
In this release the ``python -m isal.igzip`` relatively slow decompression rate

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def build_isa_l(compiler_command: str, compiler_options: str):
170170

171171
setup(
172172
name="isal",
173-
version="0.11.0",
173+
version="0.11.1",
174174
description="Faster zlib and gzip compatible compression and "
175175
"decompression by providing python bindings for the ISA-L "
176176
"library.",

src/isal/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@
3939
"__version__"
4040
]
4141

42-
__version__ = "0.11.0"
42+
__version__ = "0.11.1"

src/isal/igzip_lib.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,8 @@ cdef class IgzipDecompressor:
481481
return b""
482482
if self.eof:
483483
self.needs_input = False
484-
if self.avail_in_real > 0:
485-
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, self.avail_in_real)
486-
self.unused_data = self._view_bitbuffer() + new_data
484+
new_data = PyBytes_FromStringAndSize(<char *>self.stream.next_in, self.avail_in_real)
485+
self.unused_data = self._view_bitbuffer() + new_data
487486
elif self.avail_in_real == 0:
488487
self.stream.next_in = NULL
489488
self.needs_input = True

tests/test_igzip_lib.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@
1717
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
20-
20+
import gzip
2121
import itertools
2222
import os
2323
import pickle
24+
import zlib
2425
from typing import NamedTuple
2526

2627
from isal import igzip_lib
@@ -43,6 +44,8 @@ class Flag(NamedTuple):
4344

4445

4546
DATA = RAW_DATA[:128 * 1024]
47+
ZLIB_COMPRESSED = zlib.compress(DATA)
48+
GZIP_COMPRESSED = gzip.compress(DATA)
4649

4750
COMPRESS_LEVELS = list(range(4))
4851
HIST_BITS = list(range(16))
@@ -223,3 +226,29 @@ def test_failure(self):
223226
# Make sure there are no internal consistencies
224227
with pytest.raises(Exception):
225228
igzd.decompress(self.BAD_DATA * 30)
229+
230+
231+
@pytest.mark.parametrize("test_offset", range(5))
232+
def test_igzip_decompressor_raw_deflate_unused_data_zlib(test_offset):
233+
data = zlib.compress(b"bla")
234+
no_header = data[2:]
235+
trailer = data[-4:]
236+
raw_deflate_incomplete_trailer = no_header[:-test_offset]
237+
true_unused_data = trailer[:-test_offset]
238+
igzd = IgzipDecompressor(flag=DECOMP_DEFLATE)
239+
igzd.decompress(raw_deflate_incomplete_trailer)
240+
if igzd.eof:
241+
assert igzd.unused_data == true_unused_data
242+
243+
244+
@pytest.mark.parametrize("test_offset", range(9))
245+
def test_igzip_decompressor_raw_deflate_unused_data_gzip(test_offset):
246+
data = gzip.compress(b"bla")
247+
no_header = data[10:]
248+
trailer = data[-8:]
249+
raw_deflate_incomplete_trailer = no_header[:-test_offset]
250+
true_unused_data = trailer[:-test_offset]
251+
igzd = IgzipDecompressor(flag=DECOMP_DEFLATE)
252+
igzd.decompress(raw_deflate_incomplete_trailer)
253+
if igzd.eof:
254+
assert igzd.unused_data == true_unused_data

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ passenv=
99
PYTHON_ISAL_LINK_DYNAMIC
1010
commands =
1111
# Create HTML coverage report for humans and xml coverage report for external services.
12-
coverage run --source=isal -m py.test tests
12+
coverage run --branch --source=isal -m py.test tests
1313
# Ignore errors during report generation. Pypy does not generate proper coverage reports.
1414
coverage html -i
1515
coverage xml -i

0 commit comments

Comments
 (0)