Use sys.stdout.buffer instead of sys.stdout
authorChirantan Ekbote <chirantan.ekbote@gmail.com>
Wed, 27 Mar 2013 19:57:11 +0000 (15:57 -0400)
committerChirantan Ekbote <chirantan.ekbote@gmail.com>
Wed, 27 Mar 2013 19:57:11 +0000 (15:57 -0400)
sys.stdout defaults to text mode, we need to use the underlying buffer
instead when writing binary data.

Signed-off-by: Chirantan Ekbote <chirantan.ekbote@gmail.com>
youtube_dl/utils.py

index 95bd948438830ca7f98ad82decb722de69319bdf..901b5b5ad291686fa653ea39c3d4670d8b7b9dc8 100644 (file)
@@ -329,7 +329,7 @@ def sanitize_open(filename, open_mode):
             if sys.platform == 'win32':
                 import msvcrt
                 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
-            return (sys.stdout, filename)
+            return (sys.stdout.buffer, filename)
         stream = open(encodeFilename(filename), open_mode)
         return (stream, filename)
     except (IOError, OSError) as err: