Commit 08ce2911 authored by Christian Heimes's avatar Christian Heimes

Bug #1481296: Fixed long(float('nan'))!=0L.

parent cf317f2e
......@@ -498,6 +498,10 @@ class LongTest(unittest.TestCase):
eq(x > y, Rcmp > 0, Frm("%r > %r %d", x, y, Rcmp))
eq(x >= y, Rcmp >= 0, Frm("%r >= %r %d", x, y, Rcmp))
def test_nan_inf(self):
self.assertRaises(OverflowError, long, float('inf'))
self.assertEqual(long(float('nan')), 0L)
def test_main():
test_support.run_unittest(LongTest)
......
......@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
Core and builtins
-----------------
- Bug #1481296: Fixed long(float('nan'))!=0L.
- Issue #1640: Added math.isinf(x), math.isnan(x) and math.copysign(x, y)
functions.
......
......@@ -170,6 +170,9 @@ PyLong_FromDouble(double dval)
"cannot convert float infinity to long");
return NULL;
}
if (Py_IS_NAN(dval)) {
return PyLong_FromLong(0L);
}
if (dval < 0.0) {
neg = 1;
dval = -dval;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment