Fix some reproducible `ResourceWarning`s in CI
While now I believe most (all) of the errors in CI has been solved (if we update to the latest GPAW 23.6.1 and NumPy 1.25.0), there are still a few ResourceWarning
s. This MR solves some of them.
- before: https://gitlab.com/ase/ase/-/jobs/4618498580#L212
- after: https://gitlab.com/yuzie007/ase/-/jobs/4619244370#L210
Particularly for the second commit for ulm.py
, when Reader
is being initialized, fd
is once opened in __init__
, and then the class calls read_header
inside __init__
. When some error is raised in read_header
, this is actually BEFORE the Reader
is instantiated, and thus its Reader.close
is never called, even when the Reader
is being instantiated with the with
statement. A simple fix for this may be just to close fd
explicitly when some error is raised in read_header
.