From ffa8e2fb5637db784478e0f1f3c0d260dbae972e Mon Sep 17 00:00:00 2001 From: Ross Lagerwall Date: Sat, 25 Jun 2011 09:55:10 +0200 Subject: [PATCH] Issue 12404: Remove C89 incompatible code from mmap module. Patch by Akira Kitada. --- Misc/NEWS | 3 +++ Modules/mmapmodule.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 2e33e7f5b80..bddddfa29cd 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -16,6 +16,9 @@ Core and Builtins Library ------- +- Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira + Kitada. + - Issue #11700: mailbox proxy object close methods can now be called multiple times without error, and _ProxyFile now closes the wrapped file. diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 3078279f223..a5027f51e2c 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -1188,12 +1188,13 @@ new_mmap_object(PyTypeObject *type, PyObject *args, PyObject *kwdict) # endif if (fd != -1 && fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) { if (map_size == 0) { + off_t calc_size; if (offset >= st.st_size) { PyErr_SetString(PyExc_ValueError, "mmap offset is greater than file size"); return NULL; } - off_t calc_size = st.st_size - offset; + calc_size = st.st_size - offset; map_size = calc_size; if (map_size != calc_size) { PyErr_SetString(PyExc_ValueError,