IntColumn raises TypeError on assignment of an mpz
Bug #702933 reported by
Robert Collins
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
New
|
Undecided
|
Unassigned |
Bug Description
this occurs if using gmpy - e.g.
tableinstance.
We ran into this when conch installed a __builtin__.pow() that casts into mpz.
I think it would be reasonable for intcolumn to catch TypeError and for mpz objects cast to int.
description: | updated |
To post a comment you must log in.
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.