[pypy-commit] pypy default: Fix: don't use setslice here, because _digits might occasionally be longer

arigo noreply at buildbot.pypy.org
Sat May 11 13:44:31 CEST 2013


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r63974:c40de2de60b7
Date: 2013-05-11 12:34 +0200
http://bitbucket.org/pypy/pypy/changeset/c40de2de60b7/

Log:	Fix: don't use setslice here, because _digits might occasionally be
	longer than numdigits() says.

diff --git a/rpython/rlib/rbigint.py b/rpython/rlib/rbigint.py
--- a/rpython/rlib/rbigint.py
+++ b/rpython/rlib/rbigint.py
@@ -1314,7 +1314,8 @@
 
     assert t1.sign >= 0
     assert 2*shift + t1.numdigits() <= ret.numdigits()
-    ret._digits[2*shift : 2*shift + t1.numdigits()] = t1._digits
+    for i in range(t1.numdigits()):
+        ret._digits[2*shift + i] = t1._digits[i]
 
     # Zero-out the digits higher than the ah*bh copy. */
     ## ignored, assuming that we initialize to zero
@@ -1327,7 +1328,8 @@
     t2 = al.mul(bl)
     assert t2.sign >= 0
     assert t2.numdigits() <= 2*shift # no overlap with high digits
-    ret._digits[:t2.numdigits()] = t2._digits
+    for i in range(t2.numdigits()):
+        ret._digits[i] = t2._digits[i]
 
     # Zero out remaining digits.
     ## ignored, assuming that we initialize to zero


More information about the pypy-commit mailing list