From 6fd4b36bc5dfbb6c6a3f85e14269589e6613d26d Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 2 Jan 2015 23:04:09 +0000 Subject: py: Raise exception if trying to convert inf/nan to int. --- tests/float/float2int.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/float/float2int.py') diff --git a/tests/float/float2int.py b/tests/float/float2int.py index b948755de5..42210b4413 100644 --- a/tests/float/float2int.py +++ b/tests/float/float2int.py @@ -22,3 +22,15 @@ for i in range(0,23): print('fail: 10**%u was %u digits long' % (i, digcnt)); testpass = False print("power of 10 test: %s" % (testpass and 'passed' or 'failed')) + +# test inf conversion +try: + int(float('inf')) +except OverflowError: + print("OverflowError") + +# test nan conversion +try: + int(float('nan')) +except ValueError: + print("ValueError") -- cgit v1.2.3