parameters: (self, name, mode, comptype, fileobj, bufsize)
docstring: Construct a _Stream object.
docstring_summary: Construct a _Stream object.
docstring_tokens: Construct a _Stream object .
function: def __init__(self, name, mode, comptype, fileobj, bufsize):
          """Construct a _Stream object.
          """
          self._extfileobj = True
          if fileobj is None:
              fileobj = _LowLevelFile(name, mode)
              self._extfileobj = False
  
          if comptype == '*':
              # Enable transparent compression detection for the
              # stream interface
              fileobj = _StreamProxy(fileobj)
              comptype = fileobj.getcomptype()
  
          self.name     = name or ""
          self.mode     = mode
          self.comptype = comptype
          self.fileobj  = fileobj
          self.bufsize  = bufsize
          self.buf      = b""
          self.pos      = 0
          self.closed   = False
  
          try:
              if comptype == "gz":
                  try:
                      import zlib
                  except ImportError:
                      raise CompressionError("zlib module is not available")
                  self.zlib = zlib
                  self.crc = zlib.crc32(b"")
                  if mode == "r":
                      self._init_read_gz()
                  else:
                      self._init_write_gz()
  
              if comptype == "bz2":
                  try:
                      import bz2
                  except ImportError:
                      raise CompressionError("bz2 module is not available")
                  if mode == "r":
                      self.dbuf = b""
                      self.cmp = bz2.BZ2Decompressor()
                  else:
                      self.cmp = bz2.BZ2Compressor()
          except:
              if not self._extfileobj:
                  self.fileobj.close()
              self.closed = True
              raise
function_tokens: def __init__ ( self , name , mode , comptype , fileobj , bufsize ) : self . _extfileobj = True if fileobj is None : fileobj = _LowLevelFile ( name , mode ) self . _extfileobj = False if comptype == '*' : # Enable transparent compression detection for the # stream interface fileobj = _StreamProxy ( fileobj ) comptype = fileobj . getcomptype ( ) self . name = name or "" self . mode = mode self . comptype = comptype self . fileobj = fileobj self . bufsize = bufsize self . buf = b"" self . pos = 0 self . closed = False try : if comptype == "gz" : try : import zlib except ImportError : raise CompressionError ( "zlib module is not available" ) self . zlib = zlib self . crc = zlib . crc32 ( b"" ) if mode == "r" : self . _init_read_gz ( ) else : self . _init_write_gz ( ) if comptype == "bz2" : try : import bz2 except ImportError : raise CompressionError ( "bz2 module is not available" ) if mode == "r" : self . dbuf = b"" self . cmp = bz2 . BZ2Decompressor ( ) else : self . cmp = bz2 . BZ2Compressor ( ) except : if not self . _extfileobj : self . fileobj . close ( ) self . closed = True raise