[Python-checkins] python/dist/src/Lib/test test_format.py,1.16,1.17
mwh@users.sourceforge.net
mwh@users.sourceforge.net
Fri, 11 Oct 2002 06:46:40 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv24501
Modified Files:
test_format.py
Log Message:
A test for the recent overflow-in-format-crash bug.
Only runs when sys.maxint == 2**32 - 1; different things go wrong
on a 64-bit box.
Index: test_format.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_format.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** test_format.py 8 Aug 2002 20:19:19 -0000 1.16
--- test_format.py 11 Oct 2002 13:46:32 -0000 1.17
***************
*** 184,193 ****
testboth("%x", 0x42, "42")
! # testboth("%x", -0x42, "ffffffbe") # Alas, that's specific to 32-bit machines
testboth("%x", 0x42L, "42")
testboth("%x", -0x42L, "-42")
testboth("%o", 042, "42")
! # testboth("%o", -042, "37777777736") # Alas, that's specific to 32-bit machines
testboth("%o", 042L, "42")
testboth("%o", -042L, "-42")
--- 184,193 ----
testboth("%x", 0x42, "42")
! # testboth("%x", -0x42, "ffffffbe") # specific to 32-bit boxes; see below
testboth("%x", 0x42L, "42")
testboth("%x", -0x42L, "-42")
testboth("%o", 042, "42")
! # testboth("%o", -042, "37777777736") # specific to 32-bit boxes; see below
testboth("%o", 042L, "42")
testboth("%o", -042L, "-42")
***************
*** 222,223 ****
--- 222,235 ----
test_exc('%d', '1', TypeError, "int argument required")
test_exc('%g', '1', TypeError, "float argument required")
+
+ if sys.maxint == 2**32-1:
+ # crashes 2.2.1 and earlier:
+ try:
+ "%*d"%(sys.maxint, -127)
+ except MemoryError:
+ pass
+ else:
+ raise TestFailed, '"%*d"%(sys.maxint, -127) should fail'
+ # (different things go wrong on a 64 bit box...)
+ testboth("%x", -0x42, "ffffffbe")
+ testboth("%o", -042, "37777777736")