Set stdout to binary mode under Windows (fixes issue #218)
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sat, 23 Oct 2010 10:22:42 +0000 (12:22 +0200)
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>
Sun, 31 Oct 2010 10:28:45 +0000 (11:28 +0100)
youtube-dl

index 094a4164c8c668b8dbe1bcf83215ae87b25f832f..8494be96cbebcdb4eca535f6bcb33dab99edc55d 100755 (executable)
@@ -94,6 +94,9 @@ def sanitize_open(filename, open_mode):
        """
        try:
                if filename == u'-':
+                       if sys.platform == 'win32':
+                               import msvcrt
+                               msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
                        return (sys.stdout, filename)
                stream = open(filename, open_mode)
                return (stream, filename)