Hello all. I'm getting an OverflowError error only when I run my program in pypy. I've simplified it to a couple of lines: binasciiproblem.py: import binascii value = 0 new_value = 'a' value = binascii.crc32(new_value, value) & 0xffffffff value = binascii.crc32(new_value, value) & 0xffffffff Python 2.7.1: runs without problems. PyPy 1.5 and pypy-c-jit-45752-e490f90f2aa1-linux64.tar.bz2 (7/20 nightly): Traceback (most recent call last): File "app_main.py", line 53, in run_toplevel File "binasciiproblem.py", line 6, in <module> value = binascii.crc32(new_value, value) & 0xffffffff OverflowError: long int too large to convert to int Ideas? Is this a problem in my code noticed by PyPy or a PyPy library API issue? I've been toying around with a PPM compressor and could sure use PyPy's speed boosts for the longer runs! Thanks, -Roger
Hi, On Sat, Jul 23, 2011 at 7:18 AM, Roger Flores <aidembb@yahoo.com> wrote:
value = binascii.crc32(new_value, value) & 0xffffffff value = binascii.crc32(new_value, value) & 0xffffffff
Thanks for the report. This code doesn't run on top of CPython 2.5, too, but works indeed on top of CPython 2.7. We already had troubles deciding the type of the return value of crc32(), as it's not consistent on CPython. Now I see that we have troubles with the argument too :-) It seems that crc32() and a few similar functions actually accept integers of *any* size as argument, and just truncate it. I'll just fix it in PyPy to also accept integers of any size. A bientôt, Armin.
participants (2)
-
Armin Rigo
-
Roger Flores