Skip to content

Commit f1e2b27

Browse files
authored
Merge pull request #182 from pycompression/minorbug
Prevent errors in __close__ function for unopened files.
2 parents a7d0171 + 4deee8f commit f1e2b27

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ Changelog
77
.. This document is user facing. Please word the changes in such a way
88
.. that users understand how the changes affect the new version.
99
10+
version 1.6.0-dev
11+
-----------------
12+
+ Fix an error that occurred in the ``__close__`` function when a threaded
13+
writer was initialized with incorrect parameters.
14+
1015
version 1.5.3
1116
-----------------
1217
+ Fix a bug where append mode would not work when using

src/isal/igzip_threaded.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def __init__(self,
204204
queue_size: int = 1,
205205
block_size: int = 1024 * 1024,
206206
):
207+
# File should be closed during init, so __exit__ method does not
208+
# touch the self.raw value before it is initialized.
209+
self._closed = True
207210
if "t" in mode or "r" in mode:
208211
raise ValueError("Only binary writing is supported")
209212
if "b" not in mode:
@@ -243,8 +246,8 @@ def __init__(self,
243246
self._crc = 0
244247
self.running = False
245248
self._size = 0
246-
self._closed = False
247249
self.raw = open_as_binary_stream(filename, mode)
250+
self._closed = False
248251
self._write_gzip_header()
249252
self.start()
250253

0 commit comments

Comments
 (0)