Use sys.stdout.buffer instead of sys.stdout

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>
This commit is contained in:
Chirantan Ekbote 2013-03-27 15:57:11 -04:00
parent f10b2a9c14
commit 1ee9778405
1 changed files with 1 additions and 1 deletions

View File

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