summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-10-11 13:46:32 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-10-11 13:46:32 (GMT)
commit549ab8a98d0d5981558660b414b9c0849d644795 (patch)
treeb54f2b7be95f1e9a2ff937eeec4303ef8aac0cad /Lib
parentcafe0eefc36b504d70a1838496cb15ee1c6e3968 (diff)
downloadcpython-549ab8a98d0d5981558660b414b9c0849d644795.zip
cpython-549ab8a98d0d5981558660b414b9c0849d644795.tar.gz
cpython-549ab8a98d0d5981558660b414b9c0849d644795.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_format.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index be120fb..b40e820 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -183,12 +183,12 @@ testboth("%#X", 0, "0X0")
testboth("%#X", 0L, "0X0")
testboth("%x", 0x42, "42")
-# testboth("%x", -0x42, "ffffffbe") # Alas, that's specific to 32-bit machines
+# 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") # Alas, that's specific to 32-bit machines
+# testboth("%o", -042, "37777777736") # specific to 32-bit boxes; see below
testboth("%o", 042L, "42")
testboth("%o", -042L, "-42")
@@ -221,3 +221,15 @@ if have_unicode:
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")