[pypy-svn] r47543 - pypy/dist/pypy/module/bz2

arigo at codespeak.net arigo at codespeak.net
Thu Oct 18 13:34:03 CEST 2007


Author: arigo
Date: Thu Oct 18 13:34:03 2007
New Revision: 47543

Modified:
   pypy/dist/pypy/module/bz2/interp_bz2.py
Log:
Remove this '<< 32', bogus for RPython.  Replace it with overflow checking.


Modified: pypy/dist/pypy/module/bz2/interp_bz2.py
==============================================================================
--- pypy/dist/pypy/module/bz2/interp_bz2.py	(original)
+++ pypy/dist/pypy/module/bz2/interp_bz2.py	Thu Oct 18 13:34:03 2007
@@ -80,16 +80,19 @@
 else:
     BIGCHUNK = 512 * 1024
 
-MAXINT = sys.maxint
-
 if BZ_CONFIG_ERROR:
-    if rffi.sizeof(rffi.LONG) >= 8 or rffi.sizeof(rffi.LONGLONG) >= 8:
+    if rffi.sizeof(rffi.LONG) >= 8:
         def _bzs_total_out(bzs):
             return (bzs.c_total_out_hi32 << 32) + bzs.c_total_out_lo32
     else:
+        # we can't return a long long value from here, because most
+        # callers wouldn't be able to handle it anyway
         def _bzs_total_out(bzs):
+            if bzs.c_total_out_hi32 != 0 or bzs.c_total_out_lo32 > sys.maxint:
+                raise MemoryError
             return bzs.c_total_out_lo32
 else:
+    XXX    # this case needs fixing (old bz2 library?)
     def _bzs_total_out(bzs):
         return bzs.total_out
 



More information about the Pypy-commit mailing list