Skip to content

Commit 34a72df

Browse files
committed
Make parse_coordinates() work with astropy 5.0
The exception handling in `astropy.coordinates` changed in version 5.0. This commit ensures `astroquery.utils.commons.parse_coordinates()` works with `astropy` 5.0 and also with the older versions.
1 parent f18f02b commit 34a72df

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

astroquery/utils/commons.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ def FK4CoordGenerator(*args, **kwargs):
5252
'suppress_vo_warnings',
5353
'validate_email',
5454
'ASTROPY_LT_4_1',
55-
'ASTROPY_LT_4_3']
55+
'ASTROPY_LT_4_3',
56+
'ASTROPY_LT_5_0']
5657

5758
ASTROPY_LT_4_1 = not minversion('astropy', '4.1')
5859
ASTROPY_LT_4_3 = not minversion('astropy', '4.3')
60+
ASTROPY_LT_5_0 = not minversion('astropy', '5.0')
5961

6062

6163
@deprecated('0.4.4', alternative='astroquery.query.BaseQuery._request')
@@ -172,7 +174,8 @@ def parse_coordinates(coordinates):
172174
"appropriate astropy.coordinates object.", InputWarning)
173175
raise u.UnitsError
174176
except ValueError as err:
175-
if isinstance(err.args[1], u.UnitsError):
177+
if ((ASTROPY_LT_5_0 and isinstance(err.args[1], u.UnitsError)) or
178+
(not ASTROPY_LT_5_0 and isinstance(err.__context__, u.UnitsError))):
176179
try:
177180
c = ICRSCoordGenerator(coordinates, unit='deg')
178181
warnings.warn("Coordinate string is being interpreted as an "

0 commit comments

Comments
 (0)