wangtongada / gmpy

Automatically exported from code.google.com/p/gmpy
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Outrageous shift exception #32

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
gmpy 1.04:

>>> from gmpy import mpz
>>> mpz(1) << 10**20
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Pympz_lshift outrageous shift count

Python 2.6:

>>> 1 << 10**20
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: long int too large to convert to int

Python 3.0:

>>> 1 << 10**20
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: Python int too large to convert to C long

I think gmpy should raise an OverflowError here for compatibility. It could
copy the message from Python 3.0 too.

Original issue reported on code.google.com by fredrik....@gmail.com on 23 Jun 2009 at 2:25

GoogleCodeExporter commented 8 years ago
> It could copy the message from Python 3.0 too.

On second thought, the message in gmpy is fine. But the point about the 
exception
type stands.

Original comment by fredrik....@gmail.com on 23 Jun 2009 at 2:28

GoogleCodeExporter commented 8 years ago
Thanks for the bug report. I just committed a fix courtesy of free wifi at PDX 
airport.

Original comment by casevh on 24 Jun 2009 at 12:22