> On closer inspection, this may not be all that hard-- for the
> intobject case, getintvalue() already does the right thing
> [uses an instance's __int__ if present, uses a data-type's int()
> function pointer]. Maybe all you'd need to do is get rid if
> the is_intobject() tests, and try getintvalue() directly;
> if it fails, the operation does (?).
Actually, I'm not entirely happy with the current behavior of
getintvalue(), because it will silently truncate floating point
numbers, which I think is wrong. It used to be more strict but Donald
Beaudry forced this upon me (don't ask why :-).
I agree that there are lots of places where the interpreter could be a
lot more lenient in the types of objects it accepts, however at the
moment I don't like going in there and fixing bits at random -- this
needs a little policy discussion first, and then a big sweep over a
lot of code. Not likely in 1.2...
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>