diff --git a/Lib/gzip.py b/Lib/gzip.py index 55d448dd1d7..8802adb0d9a 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -15,12 +15,21 @@ FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16 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: + i += 1L << 32 + return i + def write32(output, value): output.write(struct.pack(" 0: line = self.readline() - if line == "": break + if line == "": + break L.append(line) sizehint = sizehint - len(line) diff --git a/Misc/NEWS b/Misc/NEWS index c8334d70c4e..980e4d2ec34 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -355,6 +355,10 @@ Extension modules Library ------- +- gzip.py now handles files exceeding 2GB. Note that 4GB is still a + fundamental limitation of the underlying gzip file format (it only + has 32 bits to record the file size). + - xml.sax.saxutils.unescape has been added, to replace entity references with their entity value. @@ -365,7 +369,7 @@ Library - Various configure methods of Tkinter have been stream-lined, so that tag_configure, image_configure, window_configure now return a - dictionary when invoked with no argument. + dictionary when invoked with no argument. - Importing the readline module now no longer has the side effect of calling setlocale(LC_CTYPE, ""). The initial "C" locale, or