Skip to content

__getattr__ raises wrong excetion #164

@st31ny

Description

@st31ny

I noticed that ProtocolBase.__getattr__ raises a KeyError, although it should raise an AttributeError. (https://github.com/cwacek/python-jsonschema-objects/blob/master/python_jsonschema_objects/classbuilder.py#L241)

This causes hasattr() to fail if the property does not exist:

delattr(test, 'foo')
assert not hasattr(test, 'foo')
…
File "/usr/lib/python3/dist-packages/python_jsonschema_objects/classbuilder.py", line 241, in __getattr__  
  raise KeyError(name)
KeyError: 'foo'

`

When I change this to AttributeError the code behaves as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions