From: Jeremy Hylton Date: Tue, 23 Mar 1999 23:05:34 +0000 (+0000) Subject: use struct instead of bit-manipulate in Python X-Git-Tag: v1.5.2c1~102 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c19f9972a19431e91cd816832158c141681686b4;p=thirdparty%2FPython%2Fcpython.git use struct instead of bit-manipulate in Python --- diff --git a/Lib/gzip.py b/Lib/gzip.py index e25464caf912..e0c7c5bd5819 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -1,6 +1,7 @@ import time import string import zlib +import struct import __builtin__ # implements a python function that reads and writes a gzipped file @@ -14,29 +15,10 @@ FTEXT, FHCRC, FEXTRA, FNAME, FCOMMENT = 1, 2, 4, 8, 16 READ, WRITE = 1, 2 def write32(output, value): - t = divmod(value, 256) - b1 = chr(t[1]) - - t = divmod(t[0], 256) - b2 = chr(t[1]) - - t = divmod(t[0], 256) - b3 = chr(t[1]) - - t = divmod(t[0], 256) - b4 = chr(t[1]) - - buf = b1 + b2 + b3 + b4 - output.write(buf) - + output.write(struct.pack("