restrict the types that can be promoted to float

This commit is contained in:
Doug Hellmann 2012-12-05 10:32:24 -05:00
parent ffaaa28b37
commit d940f3f3ae

View File

@ -218,7 +218,9 @@ def validate_value(datatype, value):
value = value.decode()
elif datatype is bytes and isinstance(value, text):
value = value.encode()
elif datatype is float and not isinstance(value, float):
elif datatype is float and (isinstance(value, int)
or isinstance(value, text)
or isinstance(value, bytes)):
value = float(value)
elif not isinstance(value, datatype):
raise ValueError(