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

Prevent errors in __close__ function for unopened files. #182

Merged
merged 2 commits into from
Jan 5, 2024
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.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
Loading