Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects that implement __asdf_traverse__ are expected to have a _tag #1738

Closed
braingram opened this issue Jan 23, 2024 · 0 comments · Fixed by #1739
Closed

Objects that implement __asdf_traverse__ are expected to have a _tag #1738

braingram opened this issue Jan 23, 2024 · 0 comments · Fixed by #1739
Milestone

Comments

@braingram
Copy link
Contributor

Description of the problem

Adding __asdf_traverse__ to an object will cause info (and possibly other commands) to fail if the object does not also contain a _tag attribute.

Example of the problem

import asdf

class MyContainer:
    def __init__(self, data):
        self.data = data

    def __asdf_traverse__(self):
        return self.data

c = MyContainer([1, 2, 3])
af = asdf.AsdfFile()
af['c'] = c
af.info()

The above example produces the following error:

Traceback (most recent call last):
  File "/Users/bgraham/projects/src/asdf/traverse_error.py", line 15, in <module>
    af.info()
  File "/Users/bgraham/projects/src/asdf/asdf/_asdf.py", line 1426, in info
    lines = display.render_tree(
  File "/Users/bgraham/projects/src/asdf/asdf/_display.py", line 45, in render_tree
    info = create_tree(
  File "/Users/bgraham/projects/src/asdf/asdf/_node_info.py", line 44, in create_tree
    schema_info = NodeSchemaInfo.from_root_node(
  File "/Users/bgraham/projects/src/asdf/asdf/_node_info.py", line 285, in from_root_node
    info.set_schema_from_node(node, extension_manager)
  File "/Users/bgraham/projects/src/asdf/asdf/_node_info.py", line 242, in set_schema_from_node
    tag_def = extension_manager.get_tag_definition(node._tag)
AttributeError: 'MyContainer' object has no attribute '_tag'

System information

asdf version: main
python version: 3.10
operating system: mac osx

@braingram braingram added this to the 3.1.0 milestone Jan 23, 2024
@braingram braingram modified the milestones: 3.1.0, 3.2.0 Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant