[issue2002] Make int() fall back to trunc()

Jeffrey Yasskin report at bugs.python.org
Sun Feb 3 19:12:43 CET 2008


Jeffrey Yasskin added the comment:

> There is also part of this patch that touches classobject.c but I'm not
> yet sure what the visible effect of that change would be or what the
> change was hoping to accomplish.

All classic classes take the (m && m->nb_int) branch, so without the
change to classobject.c, they'd never hit the fallback to __trunc__.
The unfortunate side-effect is that when you call int() or long() on a
classic class without the right methods, you get an AttributeError
complaining about __trunc__ instead of about __int__. Since long()
already mistakenly complained about __int__, I didn't consider this a
showstopper, but it should be possible to fix if you want.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2002>
__________________________________


More information about the Python-bugs-list mailing list