mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they can't be triggered from Python code.
This commit is contained in:
parent
abcb59a1d8
commit
73c01d4101
25 changed files with 464 additions and 59 deletions
|
@ -975,6 +975,23 @@ tests.append(FloatTest)
|
|||
class DoubleTest(FPTest):
|
||||
typecode = 'd'
|
||||
minitemsize = 8
|
||||
|
||||
def test_alloc_overflow(self):
|
||||
a = array.array('d', [-1]*65536)
|
||||
try:
|
||||
a *= 65536
|
||||
except MemoryError:
|
||||
pass
|
||||
else:
|
||||
self.fail("a *= 2**16 didn't raise MemoryError")
|
||||
b = array.array('d', [ 2.71828183, 3.14159265, -1])
|
||||
try:
|
||||
b * 1431655766
|
||||
except MemoryError:
|
||||
pass
|
||||
else:
|
||||
self.fail("a * 1431655766 didn't raise MemoryError")
|
||||
|
||||
tests.append(DoubleTest)
|
||||
|
||||
def test_main(verbose=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue