]> granicus.if.org Git - python/commitdiff
Issue 12404: Remove C89 incompatible code from mmap module.
authorRoss Lagerwall <rosslagerwall@gmail.com>
Sat, 25 Jun 2011 08:02:37 +0000 (10:02 +0200)
committerRoss Lagerwall <rosslagerwall@gmail.com>
Sat, 25 Jun 2011 08:02:37 +0000 (10:02 +0200)
Patch by Akira Kitada.

Misc/NEWS
Modules/mmapmodule.c

index 60405dd746483f7fa20954e89d167a96a400f0bb..9dfd0aca2fd8078585f964a23ca381aebcca5389 100644 (file)
--- 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.
 
index 36ca67d3c145864cbcdbb1c94092b173e9074822..da9283bf1b783524b2158ddd2e56e874d6359428 100644 (file)
@@ -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,