diff --git a/asdf/_node_info.py b/asdf/_node_info.py index ba6b9f328..fe0e4814e 100644 --- a/asdf/_node_info.py +++ b/asdf/_node_info.py @@ -2,7 +2,7 @@ from collections import namedtuple from .schema import load_schema -from .treeutil import get_children +from .treeutil import get_children, is_container def _filter_tree(info, filters): @@ -273,7 +273,7 @@ def from_root_node( next_nodes = [] for parent, identifier, node in current_nodes: - if (isinstance(node, (dict, tuple)) or _traversable(node, extension_manager)) and id(node) in seen: + if (is_container(node) or _traversable(node, extension_manager)) and id(node) in seen: info = NodeSchemaInfo( key, parent, diff --git a/asdf/_tests/test_info.py b/asdf/_tests/test_info.py index ed25394f9..1f409dbe2 100644 --- a/asdf/_tests/test_info.py +++ b/asdf/_tests/test_info.py @@ -732,3 +732,16 @@ def __asdf_traverse__(self): captured = capsys.readouterr() assert "sentinel" in captured.out + + +def test_info_no_infinite_loop(capsys): + """ + Providing a recursive list used to cause an + infinite loop. Test this is not the case. + """ + af = asdf.AsdfFile() + af["l"] = [] + af["l"].append(af["l"]) + af.info() + captured = capsys.readouterr() + assert "recursive" in captured.out