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

Fix getattr compatibility issues and add getattr tests #145

Closed
wants to merge 1 commit into from

Conversation

fjxmlzn
Copy link

@fjxmlzn fjxmlzn commented Aug 19, 2022

The library gives incorrect behavior with getattr:

>>> from addict import Dict
>>> body = Dict(a=1)
>>> body.freeze()
>>> getattr(body, 'missing', 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../addict/addict.py", line 67, in __getattr__
    return self.__getitem__(item)
  File ".../addict/addict.py", line 71, in __missing__
    raise KeyError(name)
KeyError: 'missing'

The expected result should be 2.

This pull request fixes the issue, and adds related getattr tests.

@fjxmlzn
Copy link
Author

fjxmlzn commented Aug 19, 2022

This pull request is replaced by a better implementation #146

@fjxmlzn fjxmlzn closed this Aug 19, 2022
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 this pull request may close these issues.

1 participant