'Close the _Stream object. No operation should be
done on it afterwards.'

def close(self):

    if self.closed:
        return
    if ((self.mode == 'w') and (self.comptype != 'tar')):
        self.buf += self.cmp.flush()
    if ((self.mode == 'w') and self.buf):
        self.fileobj.write(self.buf)
        self.buf = ''
        if (self.comptype == 'gz'):
            self.fileobj.write(struct.pack('<L', (self.crc & 4294967295L)))
            self.fileobj.write(struct.pack('<L', (self.pos & 4294967295L)))
    if (not self._extfileobj):
        self.fileobj.close()
    self.closed = True
