Skip to content

Commit

Permalink
Close sequencefile if an error happens in open_reader
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Nov 24, 2023
1 parent 8f5536f commit d163823
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions screed/openscreed.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def open_reader(self, filename, *args, **kwargs):
try:
first_char = peek[0]
except IndexError as err:
sequencefile.close()
return [] # empty file

try:
Expand All @@ -89,6 +90,7 @@ def open_reader(self, filename, *args, **kwargs):
iter_fn = fastq_iter

if iter_fn is None:
sequencefile.close()
raise ValueError("unknown file format for '%s'" % filename)

self.sequencefile = sequencefile
Expand Down

0 comments on commit d163823

Please sign in to comment.