From 382a6a218b94cf13a235421e3a608494b6d23e1f Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sun, 10 Jun 2012 18:53:49 -0700 Subject: [PATCH] Set STDOUT to binary mode on Windows if needed --- src/Ophis/Main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Ophis/Main.py b/src/Ophis/Main.py index 0806a0e..e5b3f78 100644 --- a/src/Ophis/Main.py +++ b/src/Ophis/Main.py @@ -67,6 +67,12 @@ def run_all(): outfile = Ophis.CmdLine.outfile if outfile == '-': output = sys.stdout + if sys.platform == "win32": + # We can't dump our binary in test mode; that would be + # disastrous. So, we'll do some platform-specific + # things here to force our stdout to binary mode. + import os, msvcrt + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) elif outfile is None: output = file('ophis.bin', 'wb') else: