summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_mmap.py
diff options
context:
space:
mode:
authorHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-03-31 13:44:06 (GMT)
committerHirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp>2009-03-31 13:44:06 (GMT)
commit16caab00a259c1a01f8e47abdd321c42b1b6e554 (patch)
tree3f0b25ec6a9f8f9cd9e5cd5f852b46418fc280bd /Lib/test/test_mmap.py
parent6bf6367b6725dd6fd2d7d07a447117d72b31c40e (diff)
downloadcpython-16caab00a259c1a01f8e47abdd321c42b1b6e554.zip
cpython-16caab00a259c1a01f8e47abdd321c42b1b6e554.tar.gz
cpython-16caab00a259c1a01f8e47abdd321c42b1b6e554.tar.bz2
Merged revisions 70800 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r70800 | hirokazu.yamamoto | 2009-03-31 22:13:05 +0900 | 1 line Issue #5387: Fixed mmap.move crash by integer overflow. ........
Diffstat (limited to 'Lib/test/test_mmap.py')
-rw-r--r--Lib/test/test_mmap.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py
index 7e0599a..2e03673 100644
--- a/Lib/test/test_mmap.py
+++ b/Lib/test/test_mmap.py
@@ -335,6 +335,23 @@ class MmapTests(unittest.TestCase):
mf.close()
f.close()
+ # more excessive test
+ data = b"0123456789"
+ for dest in range(len(data)):
+ for src in range(len(data)):
+ for count in range(len(data) - max(dest, src)):
+ expected = data[:dest] + data[src:src+count] + data[dest+count:]
+ m = mmap.mmap(-1, len(data))
+ m[:] = data
+ m.move(dest, src, count)
+ self.assertEqual(m[:], expected)
+ m.close()
+
+ # should not crash
+ m = mmap.mmap(-1, 1)
+ self.assertRaises(ValueError, m.move, 1, 1, -1)
+ m.close()
+
def test_anonymous(self):
# anonymous mmap.mmap(-1, PAGE)
m = mmap.mmap(-1, PAGESIZE)