mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
Issue #1481296: (again!) Make conversion of a float NaN to an int or
long raise ValueError instead of returning 0. Also, change the error message for conversion of an infinity to an integer, replacing 'long' by 'integer', so that it's appropriate for both long(float('inf')) and int(float('inf')).
This commit is contained in:
parent
ff6868cf10
commit
b646757e01
3 changed files with 9 additions and 3 deletions
|
@ -745,7 +745,8 @@ class LongTest(unittest.TestCase):
|
|||
|
||||
def test_nan_inf(self):
|
||||
self.assertRaises(OverflowError, long, float('inf'))
|
||||
self.assertEqual(long(float('nan')), 0L)
|
||||
self.assertRaises(OverflowError, long, float('-inf'))
|
||||
self.assertRaises(ValueError, long, float('nan'))
|
||||
|
||||
def test_main():
|
||||
test_support.run_unittest(LongTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue