[AstroPy] Capturing pyfits warnings

jtaylor2 at stsci.edu jtaylor2 at stsci.edu
Wed Sep 15 10:06:21 EDT 2010


   I am not sure I understand exactly what is going on here, but if having the warnings module issue exceptions instead of warnings is causing another warning to be raised as an exception that you would like to remain as a warning, you can fix this by using filterwarnings and supplying a regular expression that matches just the warning that you want raised as an exception.  In your case something like:

warnings.filterwarnings('error',message='.*Warning:  File may have been.*"')

   If you contact me directly at jtaylor2 at stsci.edu with more details, especially if you can point me to a fits file that is causing the problem, I may be able to be of more help.

     Jim T.

More information about the AstroPy mailing list