Skip to content

Commit

Permalink
Only throw compression level errors in write and append modes
Browse files Browse the repository at this point in the history
  • Loading branch information
rhpvorderman committed Feb 19, 2024
1 parent 9b2556a commit 005efe9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Changelog
version 1.6.0-dev
-----------------
+ Fix a bug where compression levels for IGzipFile where checked, even when
in read mode.
+ Update statically linked ISA-L release to 2.31.0
+ Fix an error that occurred in the ``__close__`` function when a threaded
writer was initialized with incorrect parameters.
Expand Down
9 changes: 5 additions & 4 deletions src/isal/igzip.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,12 @@ def __init__(self, filename=None, mode=None,
If omitted or None, the current time is used.
"""
if not (isal_zlib.ISAL_BEST_SPEED <= compresslevel
<= isal_zlib.ISAL_BEST_COMPRESSION):
<= isal_zlib.ISAL_BEST_COMPRESSION) and "r" not in mode:
raise ValueError(
"Compression level should be between {0} and {1}.".format(
isal_zlib.ISAL_BEST_SPEED, isal_zlib.ISAL_BEST_COMPRESSION
))
f"Compression level should be between "
f"{isal_zlib.ISAL_BEST_SPEED} and "
f"{isal_zlib.ISAL_BEST_COMPRESSION}, got {compresslevel}."
)
super().__init__(filename, mode, compresslevel, fileobj, mtime)
if self.mode == WRITE:
self.compress = isal_zlib.compressobj(compresslevel,
Expand Down

0 comments on commit 005efe9

Please sign in to comment.