Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r49030:165672fb2aef
Date: 2011-11-09 17:54 +0100
http://bitbucket.org/pypy/pypy/changeset/165672fb2aef/

Log:    Copy the logic for math.fmod() from CPython 2.7.

diff --git a/pypy/rpython/lltypesystem/module/ll_math.py 
b/pypy/rpython/lltypesystem/module/ll_math.py
--- a/pypy/rpython/lltypesystem/module/ll_math.py
+++ b/pypy/rpython/lltypesystem/module/ll_math.py
@@ -223,13 +223,21 @@
 
 
 def ll_math_fmod(x, y):
-    if isinf(x) and not isnan(y):
-        raise ValueError("math domain error")
+    # fmod(x, +/-Inf) returns x for finite x.
+    if isinf(y) and isfinite(x):
+        return x
 
-    if y == 0:
-        raise ValueError("math domain error")
-
-    return math_fmod(x, y)
+    _error_reset()
+    r = math_fmod(x, y)
+    errno = rposix.get_errno()
+    if isnan(r):
+        if isnan(x) or isnan(y):
+            errno = 0
+        else:
+            errno = EDOM
+    if errno:
+        _likely_raise(errno, r)
+    return r
 
 
 def ll_math_hypot(x, y):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to