code: def make_stream(
      name,  # type: Text
      bin_file,  # type: RawIOBase
      mode="r",  # type: Text
      buffering=-1,  # type: int
      encoding=None,  # type: Optional[Text]
      errors=None,  # type: Optional[Text]
      newline="",  # type: Optional[Text]
      line_buffering=False,  # type: bool
      **kwargs  # type: Any
  ):
      # type: (...) -> IO
      
      reading = "r" in mode
      writing = "w" in mode
      appending = "a" in mode
      binary = "b" in mode
      if "+" in mode:
          reading = True
          writing = True
  
      encoding = None if binary else (encoding or "utf-8")
  
      io_object = RawWrapper(bin_file, mode=mode, name=name)  # type: io.IOBase
      if buffering >= 0:
          if reading and writing:
              io_object = io.BufferedRandom(
                  typing.cast(io.RawIOBase, io_object),
                  buffering or io.DEFAULT_BUFFER_SIZE,
              )
          elif reading:
              io_object = io.BufferedReader(
                  typing.cast(io.RawIOBase, io_object),
                  buffering or io.DEFAULT_BUFFER_SIZE,
              )
          elif writing or appending:
              io_object = io.BufferedWriter(
                  typing.cast(io.RawIOBase, io_object),
                  buffering or io.DEFAULT_BUFFER_SIZE,
              )
  
      if not binary:
          io_object = io.TextIOWrapper(
              io_object,
              encoding=encoding,
              errors=errors,
              newline=newline,
              line_buffering=line_buffering,
          )
  
      return io_object
docs: Take a Python 2.x binary file and return an IO Stream.