def __init__(self, name, mode, comptype, fileobj, bufsize):
self._extfileobj = True<EOL>if fileobj is None:<EOL><INDENT>fileobj = _LowLevelFile(name, mode)<EOL>self._extfileobj = False<EOL><DEDENT>if comptype == '<STR_LIT:*>':<EOL><INDENT>fileobj = _StreamProxy(fileobj)<EOL>comptype = fileobj.getcomptype()<EOL><DEDENT>self.name     = name or "<STR_LIT>"<EOL>self.mode     = mode<EOL>self.comptype = comptype<EOL>self.fileobj  = fileobj<EOL>self.bufsize  = bufsize<EOL>self.buf      = b"<STR_LIT>"<EOL>self.pos      = <NUM_LIT:0><EOL>self.closed   = False<EOL>try:<EOL><INDENT>if comptype == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>import zlib<EOL><DEDENT>except ImportError:<EOL><INDENT>raise CompressionError("<STR_LIT>")<EOL><DEDENT>self.zlib = zlib<EOL>self.crc = zlib.crc32(b"<STR_LIT>")<EOL>if mode == "<STR_LIT:r>":<EOL><INDENT>self._init_read_gz()<EOL><DEDENT>else:<EOL><INDENT>self._init_write_gz()<EOL><DEDENT><DEDENT>if comptype == "<STR_LIT>":<EOL><INDENT>try:<EOL><INDENT>import bz2<EOL><DEDENT>except ImportError:<EOL><INDENT>raise CompressionError("<STR_LIT>")<EOL><DEDENT>if mode == "<STR_LIT:r>":<EOL><INDENT>self.dbuf = b"<STR_LIT>"<EOL>self.cmp = bz2.BZ2Decompressor()<EOL><DEDENT>else:<EOL><INDENT>self.cmp = bz2.BZ2Compressor()<EOL><DEDENT><DEDENT><DEDENT>except:<EOL><INDENT>if not self._extfileobj:<EOL><INDENT>self.fileobj.close()<EOL><DEDENT>self.closed = True<EOL>raise<EOL><DEDENT>
Construct a _Stream object.