From c7da98d7a78388041637b42ab520c45de784954d Mon Sep 17 00:00:00 2001 From: hpk Date: Tue, 22 Jul 2008 21:17:17 +0200 Subject: [PATCH] [svn r56722] porting the windows-execnet 56717 and 56718 fixes to other active branches --HG-- branch : trunk --- py/execnet/inputoutput.py | 10 +++++----- py/execnet/register.py | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/py/execnet/inputoutput.py b/py/execnet/inputoutput.py index 2d431ec62..4d80b600a 100644 --- a/py/execnet/inputoutput.py +++ b/py/execnet/inputoutput.py @@ -58,7 +58,11 @@ import sys class Popen2IO: server_stmt = """ -import sys, StringIO +import os, sys, StringIO +if sys.platform == "win32": + import msvcrt + msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY) + msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) io = Popen2IO(sys.stdout, sys.stdin) sys.stdout = sys.stderr = StringIO.StringIO() #try: @@ -70,10 +74,6 @@ sys.stdout = sys.stderr = StringIO.StringIO() error = (IOError, OSError, EOFError) def __init__(self, infile, outfile): - if sys.platform == 'win32': - import msvcrt - msvcrt.setmode(infile.fileno(), os.O_BINARY) - msvcrt.setmode(outfile.fileno(), os.O_BINARY) self.outfile, self.infile = infile, outfile self.readable = self.writeable = True self.lock = thread.allocate_lock() diff --git a/py/execnet/register.py b/py/execnet/register.py index 7422366d4..b08fdd6dc 100644 --- a/py/execnet/register.py +++ b/py/execnet/register.py @@ -51,6 +51,10 @@ class InstallableGateway(gateway.Gateway): class PopenCmdGateway(InstallableGateway): def __init__(self, cmd): infile, outfile = os.popen2(cmd) + if sys.platform == 'win32': + import msvcrt + msvcrt.setmode(infile.fileno(), os.O_BINARY) + msvcrt.setmode(outfile.fileno(), os.O_BINARY) io = inputoutput.Popen2IO(infile, outfile) super(PopenCmdGateway, self).__init__(io=io)