From 222ebdaba4c536a1527ad493d9fa93b17ddd33eb Mon Sep 17 00:00:00 2001 From: James Chiang Date: Mon, 4 Jan 2021 18:01:53 -0800 Subject: [PATCH] use fits.open context to avoid unclosed file --- python/lsst/eotest/image_utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/lsst/eotest/image_utils.py b/python/lsst/eotest/image_utils.py index cf386e39..ff7c402d 100644 --- a/python/lsst/eotest/image_utils.py +++ b/python/lsst/eotest/image_utils.py @@ -26,7 +26,9 @@ def __init__(self, infile, hdu=0): except: # This exception occurs when DM stack encounters a "." in # a FITS header keyword. - self.header = fits.open(infile)[hdu].header + with fits.open(infile) as hdulist: + self.header = dict() + self.header.update(hdulist[hdu].header) def get(self, key): return self(key)