Skip to content

Fix some reproducible `ResourceWarning`s in CI

Yuji Ikeda requested to merge yuzie007/ase:fix-resource-warnings into master

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 ResourceWarnings. This MR solves some of them.

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.

Merge request reports