[pypy-commit] pypy math-improvements: Fix for issue #2946 ?

stian pypy.commits at gmail.com
Thu Feb 7 06:13:43 EST 2019


Author: stian
Branch: math-improvements
Changeset: r95882:9bb63f07b007
Date: 2019-02-07 12:13 +0100
http://bitbucket.org/pypy/pypy/changeset/9bb63f07b007/

Log:	Fix for issue #2946 ?

diff --git a/pypy/objspace/std/intobject.py b/pypy/objspace/std/intobject.py
--- a/pypy/objspace/std/intobject.py
+++ b/pypy/objspace/std/intobject.py
@@ -506,8 +506,14 @@
 
         try:
             result = _pow(space, x, y, z)
-        except (OverflowError, ValueError):
+        except OverflowError:
             return _pow_ovf2long(space, x, self, y, w_exponent, w_modulus)
+        except ValueError:
+            # float result, so let avoid a roundtrip in rbigint.
+            self = self.descr_float(space)
+            w_exponent = w_exponent.descr_float(space)
+            return space.pow(self, w_exponent, space.w_None)
+            
         return space.newint(result)
 
     @unwrap_spec(w_modulus=WrappedDefault(None))


More information about the pypy-commit mailing list