docs: def get_wrapped_stream(stream, encoding=None, errors="replace"):
      """
      Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream.
  
      :param stream: A stream instance to wrap
      :param str encoding: The encoding to use for the stream
      :param str errors: The error handler to use, default "replace"
      :returns: A new, wrapped stream
      :rtype: :class:`StreamWrapper`
      """
  
      if stream is None:
          raise TypeError("must provide a stream to wrap")
      stream = _get_binary_buffer(stream)
      if stream is not None and encoding is None:
          encoding = "utf-8"
      if not encoding:
          encoding = get_output_encoding(stream)
      else:
          encoding = get_canonical_encoding_name(encoding)
      return StreamWrapper(stream, encoding, errors, line_buffering=True)