summaryrefslogtreecommitdiffstats
path: root/Lib/gzip.py
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-03-24 02:19:29 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-03-24 02:19:29 (GMT)
commit1dc54009391974ecc6d18f202be05a230a92ca60 (patch)
treecf31772659cedd334f0fef4a05586ea78bbec8ae /Lib/gzip.py
parentf8bba8e843451ac479633fe641345ade21149c44 (diff)
downloadcpython-1dc54009391974ecc6d18f202be05a230a92ca60.zip
cpython-1dc54009391974ecc6d18f202be05a230a92ca60.tar.gz
cpython-1dc54009391974ecc6d18f202be05a230a92ca60.tar.bz2
Merged revisions 61820-61823 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r61820 | gregory.p.smith | 2008-03-23 23:14:38 +0100 (Sun, 23 Mar 2008) | 2 lines replace calls to get the initial values with the raw constants. ........ r61821 | gregory.p.smith | 2008-03-24 00:43:02 +0100 (Mon, 24 Mar 2008) | 2 lines A bugfix for r61813, it would fail if the data size was >=2**32. ........ r61822 | gregory.p.smith | 2008-03-24 00:45:12 +0100 (Mon, 24 Mar 2008) | 2 lines prevent a warning from the struct module when data size >= 2**32. ........ r61823 | gregory.p.smith | 2008-03-24 01:08:01 +0100 (Mon, 24 Mar 2008) | 4 lines Have the binascii module use zlib's optimized crc32() function when available to reduce our code size (1k data table and tiny bit of code). It falls back to its own without zlib. ........
Diffstat (limited to 'Lib/gzip.py')
-rw-r--r--Lib/gzip.py5
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/gzip.py b/Lib/gzip.py
index e82cc61..45fae9f 100644
--- a/Lib/gzip.py
+++ b/Lib/gzip.py
@@ -17,7 +17,6 @@ READ, WRITE = 1, 2
def U32(i):
"""Return i as an unsigned integer, assuming it fits in 32 bits.
-
If it's >= 2GB when viewed as a 32-bit unsigned int, return a long.
"""
if i < 0:
@@ -320,7 +319,7 @@ class GzipFile:
if crc32 != self.crc:
raise IOError("CRC check failed %s != %s" % (hex(crc32),
hex(self.crc)))
- elif isize != self.size:
+ elif isize != (self.size & 0xffffffff):
raise IOError("Incorrect length of data produced")
def close(self):
@@ -328,7 +327,7 @@ class GzipFile:
self.fileobj.write(self.compress.flush())
write32u(self.fileobj, self.crc)
# self.size may exceed 2GB, or even 4GB
- write32u(self.fileobj, self.size)
+ write32u(self.fileobj, self.size & 0xffffffff)
self.fileobj = None
elif self.mode == READ:
self.fileobj = None