Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.5.3 #180

Merged
merged 4 commits into from
Nov 24, 2023
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
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Changelog
.. This document is user facing. Please word the changes in such a way
.. that users understand how the changes affect the new version.
version 1.5.3
-----------------
+ Fix a bug where append mode would not work when using
``igzip_threaded.open``.

version 1.5.2
-----------------
+ Fix a bug where a filehandle remained opened when ``igzip_threaded.open``
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def build_isa_l():

setup(
name="isal",
version="1.5.2",
version="1.5.3",
description="Faster zlib and gzip compatible compression and "
"decompression by providing python bindings for the ISA-L "
"library.",
Expand All @@ -145,7 +145,7 @@ def build_isa_l():
long_description_content_type="text/x-rst",
cmdclass={"build_ext": BuildIsalExt},
license="PSF-2.0",
keywords="isal isa-l compression deflate gzip igzip",
keywords="isal isa-l compression deflate gzip igzip threads",
zip_safe=False,
packages=find_packages('src'),
package_dir={'': 'src'},
Expand Down
2 changes: 1 addition & 1 deletion src/isal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
"__version__"
]

__version__ = "1.5.2"
__version__ = "1.5.3"
8 changes: 7 additions & 1 deletion src/isal/igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
gzip_file = io.BufferedWriter(
_ThreadedGzipWriter(
filename,
mode.replace("t", "b"),
block_size=block_size,
level=compresslevel,
threads=threads
Expand Down Expand Up @@ -197,11 +198,16 @@
"""
def __init__(self,
filename,
mode: str = "wb",
level: int = isal_zlib.ISAL_DEFAULT_COMPRESSION,
threads: int = 1,
queue_size: int = 1,
block_size: int = 1024 * 1024,
):
if "t" in mode or "r" in mode:
raise ValueError("Only binary writing is supported")

Check warning on line 208 in src/isal/igzip_threaded.py

View check run for this annotation

Codecov / codecov/patch

src/isal/igzip_threaded.py#L208

Added line #L208 was not covered by tests
if "b" not in mode:
mode += "b"

Check warning on line 210 in src/isal/igzip_threaded.py

View check run for this annotation

Codecov / codecov/patch

src/isal/igzip_threaded.py#L210

Added line #L210 was not covered by tests
self.lock = threading.Lock()
self.exception: Optional[Exception] = None
self.level = level
Expand Down Expand Up @@ -238,7 +244,7 @@
self.running = False
self._size = 0
self._closed = False
self.raw = open_as_binary_stream(filename, "wb")
self.raw = open_as_binary_stream(filename, mode)
self._write_gzip_header()
self.start()

Expand Down
22 changes: 22 additions & 0 deletions tests/test_igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,25 @@ def test_writer_write_after_close(threads):
with pytest.raises(ValueError) as error:
f.write(b"abc")
error.match("closed")


def test_igzip_threaded_append(tmp_path):
test_file = tmp_path / "test.txt.gz"
with igzip_threaded.open(test_file, "wb") as f:
f.write(b"AB")
with igzip_threaded.open(test_file, mode="ab") as f:
f.write(b"CD")
with gzip.open(test_file, "rb") as f:
contents = f.read()
assert contents == b"ABCD"


def test_igzip_threaded_append_text_mode(tmp_path):
test_file = tmp_path / "test.txt.gz"
with igzip_threaded.open(test_file, "wt") as f:
f.write("AB")
with igzip_threaded.open(test_file, mode="at") as f:
f.write("CD")
with gzip.open(test_file, "rt") as f:
contents = f.read()
assert contents == "ABCD"
Loading