fix setting None, NotLoaded and NotAvailable values on fields
This commit is contained in:
parent
3a44948b7c
commit
4ea7872ba4
1 changed files with 10 additions and 8 deletions
|
|
@ -313,14 +313,16 @@ class CapBaseObject(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
object.__setattr__(self, name, value)
|
object.__setattr__(self, name, value)
|
||||||
else:
|
else:
|
||||||
try:
|
if value not in (NotLoaded, NotAvailable, None):
|
||||||
# Try to convert value to the wanted one.
|
try:
|
||||||
value = attr.convert(value)
|
# Try to convert value to the wanted one.
|
||||||
except Exception:
|
value = attr.convert(value)
|
||||||
# error during conversion, it will probably not
|
except Exception:
|
||||||
# match the wanted following types, so we'll
|
# error during conversion, it will probably not
|
||||||
# raise ValueError.
|
# match the wanted following types, so we'll
|
||||||
pass
|
# raise ValueError.
|
||||||
|
pass
|
||||||
|
|
||||||
if not isinstance(value, attr.types) and \
|
if not isinstance(value, attr.types) and \
|
||||||
value is not NotLoaded and \
|
value is not NotLoaded and \
|
||||||
value is not NotAvailable and \
|
value is not NotAvailable and \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue