mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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.
This commit is contained in:
parent
d1cfc8ade1
commit
0e6bc8c260
5 changed files with 68 additions and 13 deletions
|
@ -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'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue