def parse_set(self, value, from_db):
if not isinstance(value, (int, long, float, Decimal)):
raise TypeError("Expected int, found %r: %r" % (type(value), value))
return int(value)
The intent of this code is to only accept "number" type values, rather than anything that has an __int__ that succeeds. For instance, we want the following to raise an error:
foo.int_column = '42'
I'm not sure of what the best course of action is. I don't think we want to be checking for every possible number-like type that has ever been created individually.
So, the problem code is in IntVariable:
def parse_set(self, value, from_db):
% (type(value), value))
if not isinstance(value, (int, long, float, Decimal)):
raise TypeError("Expected int, found %r: %r"
return int(value)
The intent of this code is to only accept "number" type values, rather than anything that has an __int__ that succeeds. For instance, we want the following to raise an error:
foo.int_column = '42'
I'm not sure of what the best course of action is. I don't think we want to be checking for every possible number-like type that has ever been created individually.