Better exception for trying to set a unsettable property on wrap
Opened this issue · 0 comments
dannyroberts commented
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.