\end{methoddesc}
\begin{methoddesc}{resize}{\var{newsize}}
+ Resizes the map and the underlying file, if any.
If the mmap was created with \constant{ACCESS_READ} or
\constant{ACCESS_COPY}, resizing the map will throw a \exception{TypeError} exception.
\end{methoddesc}
else:
verify(0, 'Could seek beyond the new size')
+ # Check that the underlying file is truncated too
+ # (bug #728515)
+ f = open(TESTFN)
+ f.seek(0, 2)
+ verify(f.tell() == 512, 'Underlying file not truncated')
+ f.close()
+ verify(m.size() == 512, 'New size not reflected in file')
+
m.close()
finally:
Extension Modules
-----------------
+- Bug #728515: mmap.resize() now resizes the file on Unix as it did
+ on Windows.
+
- Bug #1234979: For the argument of thread.Lock.acquire, the Windows
implemented treated all integer values except 1 as false.
return NULL;
#else
} else {
+ if (ftruncate(self->fd, new_size) == -1) {
+ PyErr_SetFromErrno(mmap_module_error);
+ return NULL;
+ }
+
void *newmap;
#ifdef MREMAP_MAYMOVE
if (m_obj == NULL) {return NULL;}
m_obj->size = (size_t) map_size;
m_obj->pos = (size_t) 0;
- m_obj->fd = fd;
+ m_obj->fd = dup(fd);
+ if (m_obj->fd == -1) {
+ Py_DECREF(m_obj);
+ PyErr_SetFromErrno(mmap_module_error);
+ return NULL;
+ }
m_obj->data = mmap(NULL, map_size,
prot, flags,
fd, 0);