Commit f3e938ac authored by Vincent Pelletier's avatar Vincent Pelletier

caucase.utils: Do not wrap StreamWriter in another StreamWriter.

parent 9502555b
...@@ -507,7 +507,10 @@ def toUnicodeWritableStream(writable_stream, encoding='ascii'): ...@@ -507,7 +507,10 @@ def toUnicodeWritableStream(writable_stream, encoding='ascii'):
Otherwise, returns a writable stream accepting unicode, and sending it to Otherwise, returns a writable stream accepting unicode, and sending it to
writable_stream encoded with given encoding. writable_stream encoded with given encoding.
""" """
if getattr(writable_stream, 'encoding', None) is not None: if (
isinstance(writable_stream, codecs.StreamWriter) or
getattr(writable_stream, 'encoding', None) is not None
):
return writable_stream return writable_stream
return codecs.getwriter(encoding)(writable_stream) return codecs.getwriter(encoding)(writable_stream)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment