summaryrefslogtreecommitdiffstats
path: root/Modules/mmapmodule.c
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2018-08-22 18:21:05 (GMT)
committerGitHub <noreply@github.com>2018-08-22 18:21:05 (GMT)
commite7d4b2f205c711d056bea73a0093e2e2b200544b (patch)
tree3a442a760dd83416b2141757f4bf546b623b6f36 /Modules/mmapmodule.c
parent28853a249b1d0c890b7e9ca345290bb8c1756446 (diff)
downloadcpython-e7d4b2f205c711d056bea73a0093e2e2b200544b.zip
cpython-e7d4b2f205c711d056bea73a0093e2e2b200544b.tar.gz
cpython-e7d4b2f205c711d056bea73a0093e2e2b200544b.tar.bz2
bpo-2122: Make mmap.flush() behave same on all platforms (GH-8692)
Previously, its behavior was platform-dependent and there was no error checking under Windows.
Diffstat (limited to 'Modules/mmapmodule.c')
-rw-r--r--Modules/mmapmodule.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 27030db..af9cd7e 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -569,18 +569,21 @@ mmap_flush_method(mmap_object *self, PyObject *args)
}
if (self->access == ACCESS_READ || self->access == ACCESS_COPY)
- return PyLong_FromLong(0);
+ Py_RETURN_NONE;
#ifdef MS_WINDOWS
- return PyLong_FromLong((long) FlushViewOfFile(self->data+offset, size));
+ if (!FlushViewOfFile(self->data+offset, size)) {
+ PyErr_SetFromWindowsErr(GetLastError());
+ return NULL;
+ }
+ Py_RETURN_NONE;
#elif defined(UNIX)
- /* XXX semantics of return value? */
/* XXX flags for msync? */
if (-1 == msync(self->data + offset, size, MS_SYNC)) {
PyErr_SetFromErrno(PyExc_OSError);
return NULL;
}
- return PyLong_FromLong(0);
+ Py_RETURN_NONE;
#else
PyErr_SetString(PyExc_ValueError, "flush not supported on this system");
return NULL;