Skip to content

Commit

Permalink
Make sure the file is closed if ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
fujiisoup committed Nov 11, 2024
1 parent 3779b70 commit a2f25d7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sif_parser/sif_open.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def np_open(sif_file, ignore_corrupt=False, lazy=None):
except ValueError:
data = data[:i]
if not ignore_corrupt:
if will_close:
f.close()
raise ValueError(
'The file might be corrupt. Number of files should be {} '
'according to the header, but only {} is found in the file.'
Expand Down

0 comments on commit a2f25d7

Please sign in to comment.