-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
With astropy 1.3.3 and python 3.5 (and apparently also the current master branch), the following code
% cat dummy.py
import warnings
from astropy.io import fits
warnings.simplefilter(action='error', category=ResourceWarning)
try:
fits.open('dummy.dat')
except OSError as e:
print("--> {}".format(e))
produces this output (the problem is the ResourceWarning that is being raised):
% python dummy.py
--> Header missing END card.
Exception ignored in: <_io.FileIO name='dummy.dat' mode='rb' closefd=True>
ResourceWarning: unclosed file <_io.FileIO name='dummy.dat' mode='rb' closefd=True>
for an invalid FITS file, such as
% cat dummy.dat
# A B
0.5 1.65
There has been some discussion of this at #6082 (comment) but it seems worth a separate issue.
Note that this may seem an odd thing to do - i.e. use a FITS open command on a non-FITS file - but it would be useful to https://github.com/sherpa/sherpa to handle this without the warning (since we do some odd things in the name of not breaking user expectations). At present we have to skip these warnings in our tests and it would be preferable to have warning-free code as much as possible.
Reactions are currently unavailable