Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Changelog

version 1.10.0-dev
------------------
+ Fix the gzip header that ``igzip_threaded.open`` writes when ``threads`` is
not 0. It had the XFL and OS bytes swapped, so the ``file`` command reported
the output as coming from VM/CMS or a FAT file system.
+ Fix pickling of ``isal_zlib.error`` (``igzip_lib.IsalError``). An error
raised in a ``multiprocessing`` worker process did not reach the parent
process. Tracebacks now show ``isal.igzip_lib.IsalError`` instead of
Expand Down
2 changes: 1 addition & 1 deletion src/isal/igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _write_gzip_header(self):
os = 0xff
xfl = 4 if self.level == 0 else 0
self.raw.write(struct.pack(
"BBBBIBB", magic1, magic2, method, flags, mtime, os, xfl))
"BBBBIBB", magic1, magic2, method, flags, mtime, xfl, os))

def start(self):
self.running = True
Expand Down
13 changes: 13 additions & 0 deletions tests/test_igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@ def test_threaded_write(tmp_path, mode, threads, block_size):
assert test_data == out_data


@pytest.mark.parametrize(["level", "threads"],
list(itertools.product([0, 1, 2, 3], [1, 2])))
def test_threaded_write_header_xfl_os(level, threads):
buffer = io.BytesIO()
with igzip_threaded.open(buffer, "wb", compresslevel=level,
threads=threads) as f:
f.write(b"thisisatest")
# RFC 1952 puts XFL before OS. IGzipFile writes the same two bytes:
# XFL 4 (fastest) at level 0, else 0, and OS 255 (unknown).
xfl = 4 if level == 0 else 0
assert buffer.getvalue()[8:10] == bytes([xfl, 255])


def test_threaded_open_no_threads():
with tempfile.TemporaryFile("rb") as tmp:
klass = igzip_threaded.open(tmp, "rb", threads=0)
Expand Down
Loading