From 5cc5cffc2fcfbfcf49f382eda6664d72057a9749 Mon Sep 17 00:00:00 2001 From: Vadim Markovtsev Date: Tue, 16 Oct 2018 17:42:22 +0200 Subject: [PATCH 1/2] Gracefully handle missing astropy in _open_impl --- asdf/asdf.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/asdf/asdf.py b/asdf/asdf.py index 44b482726..a5e2b6af3 100644 --- a/asdf/asdf.py +++ b/asdf/asdf.py @@ -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, From f95deb8d7d683724708a9509b0e8f3e8942334ac Mon Sep 17 00:00:00 2001 From: Daniel D'Avella Date: Tue, 16 Oct 2018 11:57:21 -0400 Subject: [PATCH 2/2] Update change log --- CHANGES.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 1a8555a88..c4abc8707 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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) ------------------