Skip to content

Missing attrdict attributes are not always handled correctly #47

@DavidHuber-NOAA

Description

@DavidHuber-NOAA

Expected behavior
If an attribute or key is missing from an attrdict object, it should raise an AttributeError or KeyError on the missing key.

Current behavior
The attrdict class sometimes instead raises an AttributeError on a missing __frozen attribute.

Machines affected
All

To Reproduce
For the global workflow, declare the HOMEgfs environment variable and run setup_xml.py.

Context
Reported many times by users, including here: NOAA-EMC/global-workflow#3161.

Detailed Description
This error is raised by these lines:

def __missing__(self, name):
if object.__getattribute__(self, '__frozen'):
raise KeyError(name)
raise KeyError(name)

Possible Implementation
I see two options: create a __getattr__ method to handle missing attributes or, in the lines above, use hasattr() to first check if __frozen is an attribute of the attrdict object.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions