(self, stream, preserve=())
return OutputStreamWrapper(stream, self, preserve)
Wrap a stream so that we can write codepage bytes to it.
Wrap a stream so that we can write codepage bytes to it.
Wrap a stream so that we can write codepage bytes to it .
def wrap_output_stream(self, stream, preserve=()):
        """Wrap a stream so that we can write codepage bytes to it."""
        # check for file-like objects that expect unicode, raw output otherwise
        if not isinstance(stream, (
                io.TextIOWrapper, io.StringIO,
                codecs.StreamReaderWriter, codecs.StreamWriter,
            )):
            return stream
        return OutputStreamWrapper(stream, self, preserve)
def wrap_output_stream ( self , stream , preserve = ( ) ) : # check for file-like objects that expect unicode, raw output otherwise if not isinstance ( stream , ( io . TextIOWrapper , io . StringIO , codecs . StreamReaderWriter , codecs . StreamWriter , ) ) : return stream return OutputStreamWrapper ( stream , self , preserve )