From cc3be04cd7a34a109cd460a9674463a198f16ae4 Mon Sep 17 00:00:00 2001 From: "Violet M. Harvey" <95004367+vmharvey@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:08:14 +1030 Subject: [PATCH] Fix exception raised by non-eventio files --- src/eventio/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eventio/base.py b/src/eventio/base.py index 89aaa52..dfa1d01 100644 --- a/src/eventio/base.py +++ b/src/eventio/base.py @@ -63,6 +63,7 @@ def __init__(self, path, zcat=True): self.read_process = None self.zstd = False self.next = None + self._filehandle = None if not is_eventio(path): raise ValueError('File {} is not an eventio file'.format(path)) @@ -151,7 +152,8 @@ def close(self): self.read_process.stderr.close() self.read_process.wait(timeout=1) - self._filehandle.close() + if self._filehandle is not None: + self._filehandle.close() def __del__(self): self.close()