diff options
author | Ondrej Certik <ondrej.certik@gmail.com> | 2013-03-09 12:22:08 +0100 |
---|---|---|
committer | Ondrej Certik <ondrej.certik@gmail.com> | 2013-03-09 12:30:43 +0100 |
commit | 92770f4c6d6b74ee8788e621b67e757c1a21138e (patch) | |
tree | 607dc793e2f4031fc9dbf658948b8b5a60237705 /numpy/distutils | |
parent | 2fbdd9903fc9bf6e1fe797e92c0157abd67850ce (diff) | |
download | numpy-92770f4c6d6b74ee8788e621b67e757c1a21138e.tar.gz |
Implement separate checking for stdout and stderr
And enable a test for this that was failing before.
Diffstat (limited to 'numpy/distutils')
-rw-r--r-- | numpy/distutils/exec_command.py | 22 | ||||
-rw-r--r-- | numpy/distutils/tests/test_exec_command.py | 7 |
2 files changed, 14 insertions, 15 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 41f156c58..a469fc5e0 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -363,17 +363,16 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): argv = [os.environ['COMSPEC'],'/C'] + argv using_command = 1 - _has_fileno = _supports_fileno(sys.stdout) - if _has_fileno: + _so_has_fileno = _supports_fileno(sys.stdout) + _se_has_fileno = _supports_fileno(sys.stderr) + so_flush = sys.stdout.flush + se_flush = sys.stderr.flush + if _so_has_fileno: so_fileno = sys.stdout.fileno() - se_fileno = sys.stderr.fileno() - so_flush = sys.stdout.flush - se_flush = sys.stderr.flush so_dup = os.dup(so_fileno) + if _se_has_fileno: + se_fileno = sys.stderr.fileno() se_dup = os.dup(se_fileno) - else: - so_flush = sys.stdout.flush - se_flush = sys.stderr.flush outfile = temp_file_name() fout = open(outfile,'w') @@ -390,10 +389,10 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): so_flush() se_flush() - if _has_fileno: + if _so_has_fileno: os.dup2(fout.fileno(),so_fileno) - if _has_fileno: + if _se_has_fileno: if using_command: #XXX: disabled for now as it does not work from cmd under win32. # Tests fail on msys @@ -409,8 +408,9 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): so_flush() se_flush() - if _has_fileno: + if _so_has_fileno: os.dup2(so_dup,so_fileno) + if _se_has_fileno: os.dup2(se_dup,se_fileno) fout.close() diff --git a/numpy/distutils/tests/test_exec_command.py b/numpy/distutils/tests/test_exec_command.py index d9983125d..69943f140 100644 --- a/numpy/distutils/tests/test_exec_command.py +++ b/numpy/distutils/tests/test_exec_command.py @@ -66,7 +66,6 @@ def test_exec_command_stderr(): exec_command.exec_command("cd '.'") # Test non-posix version: - # Note: this test reveals a failure - #with emulate_nonposix(): - # with redirect_stderr(StringIO.StringIO()): - # exec_command.exec_command("cd '.'") + with emulate_nonposix(): + with redirect_stderr(StringIO.StringIO()): + exec_command.exec_command("cd '.'") |