Only have the workaround for astropy 2.0+, for older versions do not raise deprecations as exception
@@ -28,7 +28,7 @@ except (NameError, KeyError):
# Uncomment the following line to treat all DeprecationWarnings as
# exceptions
#
-# These warnings can be removed once pyopenssl 1.7.20+ is out. The workaround requires astropy 2.0+
+# These warnings can be removed once pyopenssl 1.7.20+ is out.
_warnings = {
(2, 7): set([
r"DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead", ]),
@@ -39,9 +39,11 @@ _warnings = {
(3, 6): set([
r"DeprecationWarning: OpenSSL.rand is deprecated - you should use os.urandom instead", ])}
+import astropy
+if int(astropy.__version__[0]) > 1:
+ # The warnings_to_ignore_by_pyver parameter was added in astropy 2.0
enable_deprecations_as_exceptions(warnings_to_ignore_by_pyver=_warnings)
-
# This is to figure out the affiliated package version, rather than
# using Astropy's
try:
