Skip to content

Commit

Permalink
Merge pull request #562 from vmarkovtsev/patch-4
Browse files Browse the repository at this point in the history
Gracefully handle missing astropy in _open_impl
  • Loading branch information
drdavella authored Oct 16, 2018
2 parents fc51e24 + f95deb8 commit 4976a59
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
- Fix bug that caused subclass of external type to be serialized by the wrong
tag. [#560]

- Fix bug that occurred when attempting to open invalid file but Astropy import
fails while checking for ASDF-in-FITS. [#562]

2.1.0 (2018-09-25)
------------------

Expand Down
12 changes: 8 additions & 4 deletions asdf/asdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,14 @@ def _open_impl(cls, self, fd, uri=None, mode='r',
ignore_missing_extensions=ignore_missing_extensions,
_extension_metadata=self._extension_metadata)
except ValueError:
pass
raise ValueError(
"Input object does not appear to be ASDF file or FITS with " +
"ASDF extension")
raise ValueError(
"Input object does not appear to be an ASDF file or a FITS with " +
"ASDF extension") from None
except ImportError:
raise ValueError(
"Input object does not appear to be an ASDF file. Cannot check " +
"if it is a FITS with ASDF extension because 'astropy' is not " +
"installed") from None
return cls._open_asdf(self, fd, uri=uri, mode=mode,
validate_checksums=validate_checksums,
do_not_fill_defaults=do_not_fill_defaults,
Expand Down

0 comments on commit 4976a59

Please sign in to comment.