From 2cc0b07a4c5a4841ebc436698b1c9c2b1a9d8350 Mon Sep 17 00:00:00 2001 From: Chris Withers Date: Fri, 9 Nov 2012 15:48:17 +0000 Subject: [PATCH] Bug #16441: avoid excessive memory usage working with large gzip 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 index 2ae7c0cffe..92a7eea0bc 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -421,7 +421,7 @@ class GzipFile(io.BufferedIOBase): 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 @@ class GzipFile(io.BufferedIOBase): # 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 index d8821b0e5c..381b1fced9 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -464,6 +464,9 @@ Library - 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 ----------------- -- 2.50.0