[issue2804] Integer right shift raises OverflowError when second operand is large

Alexander Belopolsky report at bugs.python.org
Sat May 10 02:27:00 CEST 2008


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Fri, May 9, 2008 at 7:08 PM, Martin v. Löwis <report at bugs.python.org> wrote:
..
> I'm -1 on this patch (or any other fixing the perceived problem).
> Special cases aren't special enough to break the rules.
>
> If you ever see this error in a real application, you have deeper
> problems than the exception.

That was my first reaction as well, but then I thought that it was
easy to fix because the answer is guaranteed to be 0 for ridiculously
large right shifts.  However, since the patch is not theoretically
correct, I would only be +0 on applying it.

I also note that the current requirement is that shift fits long
rather than Py_ssize_t, which may lead to a >> sys.maxsize being
invalid on platforms where sizeof(long) < sizeof(Py_ssize_t).  This
may be a problem because sys.maxsize is likely to be used as a
placeholder for an arbitrary large number.

This said, I sill don't feel strongly one way or another.

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


More information about the Python-bugs-list mailing list