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

Better exception for trying to set a unsettable property on wrap #83

Open
dannyroberts opened this issue Oct 18, 2013 · 0 comments
Open

Comments

@dannyroberts
Copy link
Member

class Foo(jsonobject.JsonObject):
    @property
    def bar(self):
        return 'bar'

In the shell:

>>> Foo.wrap({'bar': 1})
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/droberts/.virtualenvs/cchq/lib/python2.7/site-packages/jsonobject/base.py", line 582, in wrap
    self = cls(obj)
  File "/Users/droberts/.virtualenvs/cchq/lib/python2.7/site-packages/jsonobject/base.py", line 552, in __init__
    self.set_raw_value(key, value)
  File "/Users/droberts/.virtualenvs/cchq/lib/python2.7/site-packages/jsonobject/base.py", line 570, in set_raw_value
    setattr(self, key, wrapped)
  File "/Users/droberts/.virtualenvs/cchq/lib/python2.7/site-packages/jsonobject/base.py", line 654, in __setattr__
    super(JsonObjectBase, self).__setattr__(name, value)
AttributeError: can't set attribute

There's also the nastier case of a settable property that relies on another property, which can create a race condition.

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

No branches or pull requests

1 participant