]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Merged revisions 88036 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Sat, 15 Jan 2011 17:31:19 +0000 (17:31 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Sat, 15 Jan 2011 17:31:19 +0000 (17:31 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88036 | antoine.pitrou | 2011-01-15 18:25:58 +0100 (sam., 15 janv. 2011) | 3 lines

  Fix mmap and test_mmap under Windows too (followup to r88022)
........

Lib/test/test_mmap.py
Modules/mmapmodule.c

index 5b99d00dbd8b6e73b6fa3de77f8cbd2250f76c96..c20b96d1d881bf5c820b629f5d88fe623e39cc5b 100644 (file)
@@ -329,13 +329,17 @@ class MmapTests(unittest.TestCase):
         # map length with an offset doesn't cause a segfault.
         if not hasattr(os, "stat"):
             self.skipTest("needs os.stat")
-        with open(TESTFN, "wb+") as f:
-            f.write(49152 * b'm') # Arbitrary character
+        # NOTE: allocation granularity is currently 65536 under Win64,
+        # and therefore the minimum offset alignment.
+        with open(TESTFN, "wb") as f:
+            f.write((65536 * 2) * b'm') # Arbitrary character
 
         with open(TESTFN, "rb") as f:
-            mf = mmap.mmap(f.fileno(), 0, offset=40960, access=mmap.ACCESS_READ)
-            self.assertRaises(IndexError, mf.__getitem__, 45000)
-            mf.close()
+            mf = mmap.mmap(f.fileno(), 0, offset=65536, access=mmap.ACCESS_READ)
+            try:
+                self.assertRaises(IndexError, mf.__getitem__, 80000)
+            finally:
+                mf.close()
 
     def test_move(self):
         # make move works everywhere (64-bit format problem earlier)
index 199d9606fcc9c00273fecf863667532a670e50a0..bbea20844b05c7908977ed78fb6c460cf1f69dce 100644 (file)
@@ -1269,6 +1269,7 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict)
             else
                 m_obj->size = low;
 #endif
+            m_obj->size -= offset;
         } else {
             m_obj->size = map_size;
         }