mirror of
https://github.com/python/cpython.git
synced 2025-08-18 07:41:05 +00:00
Merged revisions 81904 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81904 | mark.dickinson | 2010-06-11 21:27:05 +0100 (Fri, 11 Jun 2010) | 4 lines Fix possible undefined behaviour from signed overflow in struct module. Backport of revisions 81897, 81898 and 81902 from py3k. ........
This commit is contained in:
parent
4f6ebc2db8
commit
38b4a898fd
2 changed files with 34 additions and 23 deletions
|
@ -12,7 +12,6 @@ from test.test_support import TestFailed, verbose, run_unittest
|
|||
import sys
|
||||
ISBIGENDIAN = sys.byteorder == "big"
|
||||
IS32BIT = sys.maxsize == 0x7fffffff
|
||||
del sys
|
||||
|
||||
try:
|
||||
import _struct
|
||||
|
@ -605,7 +604,12 @@ class StructTest(unittest.TestCase):
|
|||
def test_crasher(self):
|
||||
self.assertRaises(MemoryError, struct.pack, "357913941c", "a")
|
||||
|
||||
def test_count_overflow(self):
|
||||
hugecount = '{0}b'.format(sys.maxsize+1)
|
||||
self.assertRaises(struct.error, struct.calcsize, hugecount)
|
||||
|
||||
hugecount2 = '{0}b{1}H'.format(sys.maxsize//2, sys.maxsize//2)
|
||||
self.assertRaises(struct.error, struct.calcsize, hugecount2)
|
||||
|
||||
def test_main():
|
||||
run_unittest(StructTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue