--- gzip.py.orig 2008-05-24 16:11:18.000000000 -0700 +++ gzip.py 2008-05-24 16:23:49.000000000 -0700 @@ -311,6 +311,8 @@ raise IOError, "Incorrect length of data produced" def close(self): + if self.fileobj == None: + return if self.mode == WRITE: self.fileobj.write(self.compress.flush()) write32(self.fileobj, self.crc)