Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Close sequencefile if an error happens in open_reader (#106)
When running downstream projects with [`PYTHONDEVMODE=1`](https://docs.python.org/3/library/devmode.html) there is a `ResourceWarning` for unclosed files: ``` tests/test_cmd_signature.py::test_sig_kmers_1_dna_empty_seq sourmash/.tox/py310/lib/python3.10/site-packages/screed/openscreed.py:35: ResourceWarning: unclosed file <_io.BufferedReader name='/tmp/nix-shell.7nFxtp/so urmashtest_f12d2h09/query.fa'> self.iter_fn = self.open_reader(filename, *args, **kwargs) Object allocated at: File "sourmash/.tox/py310/lib/python3.10/site-packages/screed/openscreed.py", line 35 self.iter_fn = self.open_reader(filename, *args, **kwargs) ``` Turns out we didn't close the `sequencefile` in the `open_reader` method of `screed.openscreed.Open` for two error cases before raising an exception, and with the fix in this PR the warnings disappear.
- Loading branch information