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

2008-02-03 Thread Jeffrey Yasskin
Jeffrey Yasskin added the comment: Submitted as r60566. -- status: open -> closed __ Tracker <[EMAIL PROTECTED]> __ ___ Python-bugs-list mailing

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

2008-02-03 Thread Raymond Hettinger
Raymond Hettinger added the comment: Go for it. -- assignee: gvanrossum -> jyasskin resolution: -> accepted __ Tracker <[EMAIL PROTECTED]> __ _

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

2008-02-03 Thread Guido van Rossum
Guido van Rossum added the comment: > Guido, are these basically the mechanics you intended? All calls to > PyNumber_Int() and PyNumber_Long() attempt the usual path and if those > would fail, it tries __trunc__ if it exists and coerces the result of > that call back to an int or long. Yes, tha

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

2008-02-03 Thread Jeffrey Yasskin
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 cl

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

2008-02-02 Thread Raymond Hettinger
Raymond Hettinger added the comment: Guido, are these basically the mechanics you intended? All calls to PyNumber_Int() and PyNumber_Long() attempt the usual path and if those would fail, it tries __trunc__ if it exists and coerces the result of that call back to an int or long. The logic

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

2008-02-02 Thread Jeffrey Yasskin
Jeffrey Yasskin added the comment: Here's a patch to implement the fallback for both int and long. I'm pretty sure that _PyNumber_ConvertIntegralToInt() is in the wrong place. Where would be a better place for it? -- keywords: +patch nosy: +rhettinger Added file: http://bugs.python.org/f

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

2008-02-02 Thread Jeffrey Yasskin
New submission from Jeffrey Yasskin: Per http://mail.python.org/pipermail/python-dev/2008-January/076564.html. -- assignee: jyasskin messages: 62014 nosy: jyasskin priority: high severity: normal status: open title: Make int() fall back to trunc() type: behavior versions: Python 2.6, Pyt