code: def get_wrapped_stream(stream):
      
  
      if stream is None:
          raise TypeError("must provide a stream to wrap")
      encoding = getattr(stream, "encoding", None)
      encoding = get_output_encoding(encoding)
      return StreamWrapper(stream, encoding, "replace", line_buffering=True)
docs: Given a stream, wrap it in a `StreamWrapper` instance and return the wrapped stream.
  
      :param stream: A stream instance to wrap
      :returns: A new, wrapped stream
      :rtype: :class:`StreamWrapper`