diff --git a/CHANGES.rst b/CHANGES.rst index 5fc4ed299..19585e508 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,9 @@ 2.3.1 (unreleased) ------------------ +- Provide source information for ``AsdfDeprecationWarning`` that come from + extensions from external packages. [#629] + - Ensure that top-level accesses to the tree outside a closed context handler result in an ``OSError``. [#628] diff --git a/asdf/extension.py b/asdf/extension.py index 4325fc538..17d491051 100644 --- a/asdf/extension.py +++ b/asdf/extension.py @@ -192,7 +192,9 @@ def __init__(self): def _load_installed_extensions(self, group='asdf_extensions'): for entry_point in iter_entry_points(group=group): - ext = entry_point.load() + with warnings.catch_warnings(record=True) as w: + warnings.simplefilter('always', category=AsdfDeprecationWarning) + ext = entry_point.load() if not issubclass(ext, AsdfExtension): warnings.warn("Found entry point {}, from {} but it is not a " "subclass of AsdfExtension, as expected. It is " @@ -204,6 +206,10 @@ def _load_installed_extensions(self, group='asdf_extensions'): self._package_metadata[name] = (dist.project_name, dist.version) self._extensions.append(ext()) + for warning in w: + warnings.warn('{} (from {})'.format(warning.message, name), + AsdfDeprecationWarning) + @property def extensions(self): # This helps avoid a circular dependency with external packages