Skip to content

Commit 41ae78f

Browse files
committed
use yaml constructors for _IgnoreCustomTagsLoader
1 parent 4779d1f commit 41ae78f

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

asdf/_tests/test_util.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,24 @@ def test_load_yaml_recursion(tmp_path, tagged):
128128
tree = util.load_yaml(fn, tagged=tagged)
129129
assert tree["d"]["d"] is tree["d"]
130130
assert tree["l"][0] is tree["l"]
131+
132+
133+
@pytest.mark.parametrize("tagged", [True, False])
134+
def test_load_yaml_recursion_with_tags(tagged):
135+
contents = b"""#ASDF 1.0.0
136+
#ASDF_STANDARD 1.6.0
137+
%YAML 1.1
138+
%TAG ! tag:stsci.edu:asdf/
139+
--- !core/asdf-1.1.0
140+
o: &id001 !transform/remap_axes-1.4.0
141+
inputs: [x0, x1]
142+
inverse: !transform/remap_axes-1.4.0
143+
inputs: [x0, x1, x2]
144+
inverse: *id001
145+
mapping: [2, 1]
146+
outputs: [x0, x1]
147+
mapping: [0, 1, 0]
148+
outputs: [x0, x1, x2]
149+
..."""
150+
tree = util.load_yaml(io.BytesIO(contents), tagged=tagged)
151+
assert tree["o"] is tree["o"]["inverse"]["inverse"]

asdf/yamlutil.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ class _IgnoreCustomTagsLoader(_yaml_base_loader):
147147

148148
def construct_undefined(self, node):
149149
if isinstance(node, yaml.MappingNode):
150-
return self.construct_mapping(node)
150+
return self.construct_yaml_map(node)
151151
elif isinstance(node, yaml.SequenceNode):
152-
return self.construct_sequence(node)
152+
return self.construct_yaml_seq(node)
153153
elif isinstance(node, yaml.ScalarNode):
154154
return self.construct_scalar(node)
155155
return super().construct_undefined(node)

0 commit comments

Comments
 (0)