[Python-checkins] cpython (2.7): Bug #16441: avoid excessive memory usage working with large gzip files

chris.withers python-checkins at python.org
Fri Nov 9 16:54:55 CET 2012


http://hg.python.org/cpython/rev/f938d478359a
changeset:   80328:f938d478359a
branch:      2.7
parent:      80324:058ff991bdcb
user:        Chris Withers <chris at simplistix.co.uk>
date:        Fri Nov 09 15:48:17 2012 +0000
summary:
  Bug #16441: avoid excessive memory usage working with large gzip files

files:
  Lib/gzip.py |  4 ++--
  Misc/NEWS   |  3 +++
  2 files changed, 5 insertions(+), 2 deletions(-)


diff --git a/Lib/gzip.py b/Lib/gzip.py
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -421,7 +421,7 @@
             if offset < self.offset:
                 raise IOError('Negative seek in write mode')
             count = offset - self.offset
-            for i in range(count // 1024):
+            for i in xrange(count // 1024):
                 self.write(1024 * '\0')
             self.write((count % 1024) * '\0')
         elif self.mode == READ:
@@ -429,7 +429,7 @@
                 # for negative seek, rewind and do positive seek
                 self.rewind()
             count = offset - self.offset
-            for i in range(count // 1024):
+            for i in xrange(count // 1024):
                 self.read(1024)
             self.read(count % 1024)
 
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -464,6 +464,9 @@
 - Issue #6884: Fix long-standing bugs with MANIFEST.in parsing in distutils
   on Windows.
 
+- Issue #16441: Avoid excessive memory usage working with large gzip
+  files using the gzip module.
+
 Extension Modules
 -----------------
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list