Author: Vincent Prat <vivi@debian.org>
Description: Fix incompatibility with Astropy 4.1
Forwarded: not-needed
--- a/astroquery/utils/commons.py
+++ b/astroquery/utils/commons.py
@@ -51,8 +51,10 @@
            'TableList',
            'suppress_vo_warnings',
            'validate_email',
+           'ASTROPY_LT_4_0',
            'ASTROPY_LT_4_1']
 
+ASTROPY_LT_4_0 = not minversion('astropy', '4.0')
 ASTROPY_LT_4_1 = not minversion('astropy', '4.1')
 
 
@@ -389,22 +391,17 @@
             If the system is unable to create a hardlink, the file will be
             copied to the target location.
         """
-        from warnings import warn
-
         self.get_fits()
+        target_key = str(self._target)
 
-        try:
-            dldir, urlmapfn = aud._get_download_cache_locs()
-        except (IOError, OSError) as e:
-            msg = 'Remote data cache could not be accessed due to '
-            estr = '' if len(e.args) < 1 else (': ' + str(e))
-            warn(aud.CacheMissingWarning(msg + e.__class__.__name__ + estr))
-
-        with _open_shelve(urlmapfn, True) as url2hash:
-            if str(self._target) in url2hash:
-                target = url2hash[str(self._target)]
-            else:
+        # There has been some internal refactoring in astropy.utils.data
+        # so we do this check. Update when minimum required astropy changes.
+        if ASTROPY_LT_4_0:
+            if not aud.is_url_in_cache(target_key):
                 raise IOError("Cached file not found / does not exist.")
+            target = aud.download_file(target_key, cache=True)
+        else:
+            target = aud.download_file(target_key, cache=True, sources=[])
 
         if link_cache == 'hard':
             try:
@@ -470,22 +467,3 @@
     """
     tables = votable.parse(six.BytesIO(content), pedantic=False)
     return tables
-
-
-def _open_shelve(shelffn, withclosing=False):
-    """
-    Opens a shelf file.  If ``withclosing`` is True, it will be opened with
-    closing, allowing use like:
-
-        with _open_shelve('somefile',True) as s:
-            ...
-    """
-    import shelve
-    import contextlib
-
-    shelf = shelve.open(shelffn, protocol=2)
-
-    if withclosing:
-        return contextlib.closing(shelf)
-    else:
-        return shelf
