]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
use sys.stdout.buffer only on Python3
authorFilippo Valsorda <filippo.valsorda@gmail.com>
Thu, 28 Mar 2013 12:13:03 +0000 (13:13 +0100)
committerFilippo Valsorda <filippo.valsorda@gmail.com>
Thu, 28 Mar 2013 12:13:03 +0000 (13:13 +0100)
youtube_dl/utils.py

index 901b5b5ad291686fa653ea39c3d4670d8b7b9dc8..49af7d7c081e759d0e560bf81bb086ba601babe8 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.buffer, filename)
+            return (sys.stdout.buffer if hasattr(sys.stdout, 'buffer') else sys.stdout, filename)
         stream = open(encodeFilename(filename), open_mode)
         return (stream, filename)
     except (IOError, OSError) as err: