summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_long.py
diff options
context:
space:
mode:
authorWalter Dörwald <walter@livinglogic.de>2002-11-19 20:49:15 (GMT)
committerWalter Dörwald <walter@livinglogic.de>2002-11-19 20:49:15 (GMT)
commitf171540ab8d816a996c34db3f6aa4bf9cf147fba (patch)
tree001d1ff0bdea449058218d2debf6d6f8dbbcb220 /Lib/test/test_long.py
parent7a3bae410df3dd0032509b97077d0c4d98276fdd (diff)
downloadcpython-f171540ab8d816a996c34db3f6aa4bf9cf147fba.zip
cpython-f171540ab8d816a996c34db3f6aa4bf9cf147fba.tar.gz
cpython-f171540ab8d816a996c34db3f6aa4bf9cf147fba.tar.bz2
Change int() so that passing a string, unicode, float or long argument
that is outside the integer range no longer raises OverflowError, but returns a long object instead. This fixes SF bug http://www.python.org/sf/635115
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r--Lib/test/test_long.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py
index 9319734..9cab2de 100644
--- a/Lib/test/test_long.py
+++ b/Lib/test/test_long.py
@@ -267,22 +267,26 @@ def test_misc(maxdigits=MAXDIGITS):
# but long -> int should overflow for hugepos+1 and hugeneg-1
x = hugepos_aslong + 1
try:
- int(x)
- raise ValueError
+ y = int(x)
except OverflowError:
- pass
- except:
- raise TestFailed, "int(long(sys.maxint) + 1) didn't overflow"
+ raise TestFailed, "int(long(sys.maxint) + 1) mustn't overflow"
+ if not isinstance(y, long):
+ raise TestFailed("int(long(sys.maxint) + 1) should have returned long")
x = hugeneg_aslong - 1
try:
- int(x)
- raise ValueError
+ y = int(x)
except OverflowError:
- pass
- except:
- raise TestFailed, "int(long(-sys.maxint-1) - 1) didn't overflow"
+ raise TestFailed, "int(long(-sys.maxint-1) - 1) mustn't overflow"
+ if not isinstance(y, long):
+ raise TestFailed("int(long(-sys.maxint-1) - 1) should have returned long")
+ class long2(long):
+ pass
+ x = long2(1L<<100)
+ y = int(x)
+ if type(y) is not long:
+ raise TestFailed("overflowing int conversion must return long not long subtype")
# ----------------------------------- tests of auto int->long conversion
def test_auto_overflow():