Author: Armin Rigo <[email protected]>
Branch: py3.5
Changeset: r88014:61a25d2c08c5
Date: 2016-11-01 10:39 +0100
http://bitbucket.org/pypy/pypy/changeset/61a25d2c08c5/

Log:    math.gcd() argument types

diff --git a/pypy/module/math/app_math.py b/pypy/module/math/app_math.py
--- a/pypy/module/math/app_math.py
+++ b/pypy/module/math/app_math.py
@@ -1,4 +1,5 @@
 import sys
+from _operator import index
 
 def factorial(x):
     """factorial(x) -> Integral
@@ -45,8 +46,8 @@
 
 def gcd(x, y):
     """greatest common divisor of x and y"""
-    x = abs(x)
-    y = abs(y)
+    x = abs(index(x))
+    y = abs(index(y))
     while x > 0:
         x, y = y % x, x
     return y
diff --git a/pypy/module/math/test/test_math.py 
b/pypy/module/math/test/test_math.py
--- a/pypy/module/math/test/test_math.py
+++ b/pypy/module/math/test/test_math.py
@@ -369,6 +369,7 @@
         assert math.gcd(-4, -10) == 2
         assert math.gcd(0, -10) == 10
         assert math.gcd(0, 0) == 0
+        raises(TypeError, math.gcd, 0, 0.0)
 
     def test_inf_nan(self):
         import math
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to