Skip to content

Commit

Permalink
Merge pull request #182 from pycompression/minorbug
Browse files Browse the repository at this point in the history
Prevent errors in __close__ function for unopened files.
  • Loading branch information
rhpvorderman authored Jan 5, 2024
2 parents a7d0171 + 4deee8f commit f1e2b27
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
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.6.0-dev
-----------------
+ Fix an error that occurred in the ``__close__`` function when a threaded
writer was initialized with incorrect parameters.

version 1.5.3
-----------------
+ Fix a bug where append mode would not work when using
Expand Down
5 changes: 4 additions & 1 deletion src/isal/igzip_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ def __init__(self,
queue_size: int = 1,
block_size: int = 1024 * 1024,
):
# File should be closed during init, so __exit__ method does not
# touch the self.raw value before it is initialized.
self._closed = True
if "t" in mode or "r" in mode:
raise ValueError("Only binary writing is supported")
if "b" not in mode:
Expand Down Expand Up @@ -243,8 +246,8 @@ def __init__(self,
self._crc = 0
self.running = False
self._size = 0
self._closed = False
self.raw = open_as_binary_stream(filename, mode)
self._closed = False
self._write_gzip_header()
self.start()

Expand Down

0 comments on commit f1e2b27

Please sign in to comment.