[Python-3000-checkins] r59966 - in python/branches/py3k: Lib/test/test_long.py Misc/NEWS Objects/longobject.c
christian.heimes
python-3000-checkins at python.org
Tue Jan 15 03:01:21 CET 2008
Author: christian.heimes
Date: Tue Jan 15 03:01:20 2008
New Revision: 59966
Modified:
python/branches/py3k/Lib/test/test_long.py
python/branches/py3k/Misc/NEWS
python/branches/py3k/Objects/longobject.c
Log:
long(float('nan')) raises an OverflowError as discussed on the mailing list a week ago
Modified: python/branches/py3k/Lib/test/test_long.py
==============================================================================
--- python/branches/py3k/Lib/test/test_long.py (original)
+++ python/branches/py3k/Lib/test/test_long.py Tue Jan 15 03:01:20 2008
@@ -539,7 +539,7 @@
def test_nan_inf(self):
self.assertRaises(OverflowError, int, float('inf'))
- self.assertEqual(int(float('nan')), 0)
+ self.assertRaises(OverflowError, int, float('nan'))
def test_main():
test_support.run_unittest(LongTest)
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Tue Jan 15 03:01:20 2008
@@ -12,6 +12,9 @@
Core and Builtins
-----------------
+- Object/longobject.c: long(float('nan')) raises an OverflowError instead
+ of returning 0.
+
- Issue #1762972: __file__ points to the source file instead of the pyc/pyo
file if the py file exists.
Modified: python/branches/py3k/Objects/longobject.c
==============================================================================
--- python/branches/py3k/Objects/longobject.c (original)
+++ python/branches/py3k/Objects/longobject.c Tue Jan 15 03:01:20 2008
@@ -255,7 +255,9 @@
return NULL;
}
if (Py_IS_NAN(dval)) {
- return PyLong_FromLong(0L);
+ PyErr_SetString(PyExc_OverflowError,
+ "cannot convert float NaN to int");
+ return NULL;
}
if (dval < 0.0) {
neg = 1;
More information about the Python-3000-checkins
mailing list