mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Merge in release25-maint r60793:
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
73baefd7fc
commit
9d53457e59
24 changed files with 438 additions and 54 deletions
|
@ -8,6 +8,7 @@ from test.test_support import TestFailed, verbose, run_unittest, catch_warning
|
|||
|
||||
import sys
|
||||
ISBIGENDIAN = sys.byteorder == "big"
|
||||
IS32BIT = sys.maxint == 0x7fffffff
|
||||
del sys
|
||||
|
||||
try:
|
||||
|
@ -568,6 +569,13 @@ class StructTest(unittest.TestCase):
|
|||
for c in '\x01\x7f\xff\x0f\xf0':
|
||||
self.assertTrue(struct.unpack('>?', c)[0])
|
||||
|
||||
def test_crasher(self):
|
||||
if IS32BIT:
|
||||
self.assertRaises(MemoryError, struct.pack, "357913941c", "a")
|
||||
else:
|
||||
print "%s test_crasher skipped on 64bit build."
|
||||
|
||||
|
||||
|
||||
def test_main():
|
||||
run_unittest(StructTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue