diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-02-05 05:45:43 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-02-05 05:45:43 (GMT) |
commit | 0e6bc8c260f640ceee515e9873353778472e0a00 (patch) | |
tree | f567d2bbbde27ae16288e1e94edc4ff0acf13441 /Lib/test | |
parent | d1cfc8ade1f661f02286f2b81123d4d436c6d9d0 (diff) | |
download | cpython-0e6bc8c260f640ceee515e9873353778472e0a00.zip cpython-0e6bc8c260f640ceee515e9873353778472e0a00.tar.gz cpython-0e6bc8c260f640ceee515e9873353778472e0a00.tar.bz2 |
Patch #1407135, bug #1424041, make mmap.mmap(-1, length) work the same
on both Unix (SVR4 and BSD) and Windows. Restores behaviour of passing -1
for anonymous memory on Unix. Use MAP_ANONYMOUS instead of _ANON since
the latter is deprecated according to Linux (gentoo) man pages.
Should we continue to allow mmap.mmap(0, length) to work on Windows?
0 is a valid fd.
Will backport bugfix portions.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_mmap | 1 | ||||
-rw-r--r-- | Lib/test/test_mmap.py | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/output/test_mmap b/Lib/test/output/test_mmap index 1ce4943..605f840 100644 --- a/Lib/test/output/test_mmap +++ b/Lib/test/output/test_mmap @@ -34,4 +34,5 @@ test_mmap Try opening a bad file descriptor... Ensuring that passing 0 as map length sets map size to current file size. Ensuring that passing 0 as map length sets map size to current file size. + anonymous mmap.mmap(-1, PAGESIZE)... Test passed diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 6930317..d2a2477 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -283,7 +283,7 @@ def test_both(): print ' Try opening a bad file descriptor...' try: - mmap.mmap(-1, 4096) + mmap.mmap(-2, 4096) except mmap.error: pass else: @@ -380,6 +380,16 @@ def test_both(): finally: os.unlink(TESTFN) - print ' Test passed' +def test_anon(): + print " anonymous mmap.mmap(-1, PAGESIZE)..." + m = mmap.mmap(-1, PAGESIZE) + for x in xrange(PAGESIZE): + verify(m[x] == '\0', "anonymously mmap'ed contents should be zero") + + for x in xrange(PAGESIZE): + m[x] = ch = chr(x & 255) + vereq(m[x], ch) test_both() +test_anon() +print ' Test passed' |