From: Ross Lagerwall <rosslagerwall@gmail.com>
Date: Sat, 25 Jun 2011 08:02:37 +0000 (+0200)
Subject: Issue 12404: Remove C89 incompatible code from mmap module.
X-Git-Tag: v3.2.2rc1~213
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbfb9b89db6cf2f1bc63c9be9bfab476d7141181;p=python

Issue 12404: Remove C89 incompatible code from mmap module.

Patch by Akira Kitada.
---

diff --git a/Misc/NEWS b/Misc/NEWS
index 60405dd746..9dfd0aca2f 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -25,6 +25,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #12404: Remove C89 incompatible code from mmap module. Patch by Akira
+  Kitada.
+
 - Issue #12383: Fix subprocess module with env={}: don't copy the environment
   variables, start with an empty environment.
 
diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c
index 36ca67d3c1..da9283bf1b 100644
--- a/Modules/mmapmodule.c
+++ b/Modules/mmapmodule.c
@@ -1140,12 +1140,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,