Index: Lib/test/test_mmap.py =================================================================== --- Lib/test/test_mmap.py (revision 69672) +++ Lib/test/test_mmap.py (working copy) @@ -344,6 +344,24 @@ m[x] = ch = chr(x & 255) self.assertEqual(m[x], ch) + def test_anonymous_resize(self): + RESIZE = 2 * PAGESIZE + m = mmap.mmap(-1, PAGESIZE) + try: + m.resize(RESIZE) + except SystemError: + # resize() not supported + # No messages are printed, since the output of this test suite + # would then be different across platforms. + pass + else: + # resize() is supported + self.assertEqual(len(m), RESIZE) + # Check that we can no longer seek beyond the new size. + self.assertRaises(ValueError, m.seek, 1+RESIZE, 0) + finally: + m.close() + def test_extended_getslice(self): # Test extended slicing by comparing with list slicing. s = "".join(chr(c) for c in reversed(range(256))) Index: Modules/mmapmodule.c =================================================================== --- Modules/mmapmodule.c (revision 69672) +++ Modules/mmapmodule.c (working copy) @@ -431,7 +431,7 @@ #ifdef MS_WINDOWS } else { DWORD dwErrCode = 0; - DWORD off_hi, off_lo, newSizeLow, newSizeHigh; + DWORD off_hi, off_lo, newSizeLow, newSizeHigh, copySizeHigh; /* First, unmap the file view */ UnmapViewOfFile(self->data); /* Close the mapping object */ @@ -448,8 +448,9 @@ off_hi = 0; off_lo = (DWORD)self->offset; #endif + copySizeHigh = newSizeHigh; SetFilePointer(self->file_handle, - newSizeLow, &newSizeHigh, FILE_BEGIN); + newSizeLow, ©SizeHigh, FILE_BEGIN); /* Change the size of the file */ SetEndOfFile(self->file_handle); /* Create another mapping object and remap the file view */ @@ -457,8 +458,8 @@ self->file_handle, NULL, PAGE_READWRITE, - 0, - 0, + newSizeHigh, + newSizeLow, self->tagname); if (self->map_handle != NULL) { self->data = (char *) MapViewOfFile(self->map_handle,