diff options
author | Christian Heimes <christian@cheimes.de> | 2008-01-04 00:37:34 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2008-01-04 00:37:34 (GMT) |
commit | 8267d1dfe5f73007812dcb35f865fd4763e94471 (patch) | |
tree | e90dcb5c1de29d750dba16d57d359ad5cf160378 | |
parent | 0613188bc3ad62b96d5dae879814d0e8563d955c (diff) | |
download | cpython-8267d1dfe5f73007812dcb35f865fd4763e94471.zip cpython-8267d1dfe5f73007812dcb35f865fd4763e94471.tar.gz cpython-8267d1dfe5f73007812dcb35f865fd4763e94471.tar.bz2 |
Bug #1481296: Fixed long(float('nan'))!=0L.
-rw-r--r-- | Lib/test/test_long.py | 4 | ||||
-rw-r--r-- | Misc/NEWS | 2 | ||||
-rw-r--r-- | Objects/longobject.c | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 29515c7..d745350 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -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. diff --git a/Objects/longobject.c b/Objects/longobject.c index 262b40a..e2ffb35 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -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; |