Skip to content

Commit

Permalink
Prevent operations on raw file before it is successfully opened if er…
Browse files Browse the repository at this point in the history
…ror is thrown during __init__
  • Loading branch information
rhpvorderman committed Dec 24, 2023
1 parent a7d0171 commit dc4b5c3
Showing 1 changed file with 4 additions and 1 deletion.
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 dc4b5c3

Please sign in to comment.