[pypy-commit] pypy improve-rbigint: Fix a bug with floordiv caused by my power of two code that allowed div by 0

stian noreply at buildbot.pypy.org
Sat Jul 21 18:41:17 CEST 2012


Author: stian
Branch: improve-rbigint
Changeset: r56330:ea6df5628183
Date: 2012-06-25 02:30 +0200
http://bitbucket.org/pypy/pypy/changeset/ea6df5628183/

Log:	Fix a bug with floordiv caused by my power of two code that allowed
	div by 0

diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -414,10 +414,9 @@
     def floordiv(self, other):
         if other.numdigits() == 1 and other.sign == 1:
             digit = other.digit(0)
-
             if digit == 1:
                 return self
-            elif digit & (digit - 1) == 0:
+            elif digit and digit & (digit - 1) == 0:
                 div = self.rshift(ptwotable[digit])
                 return div
             


More information about the pypy-commit mailing list