From d27c37781733607d37af3e89c0ebc86f1d80c0c1 Mon Sep 17 00:00:00 2001 From: holger krekel Date: Fri, 14 Mar 2014 15:58:16 +0100 Subject: [PATCH] tentatively fix py33 and py25 compat --- _pytest/capture.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/_pytest/capture.py b/_pytest/capture.py index a4c1535e4..a63738315 100644 --- a/_pytest/capture.py +++ b/_pytest/capture.py @@ -2,6 +2,8 @@ per-test stdout/stderr capturing mechanism. """ +from __future__ import with_statement + import sys import os import tempfile @@ -366,12 +368,9 @@ class FDCapture: def writeorg(self, data): """ write a string to the original file descriptor """ - tempfp = tempfile.TemporaryFile() - try: - os.dup2(self._savefd, tempfp.fileno()) - tempfp.write(data) - finally: - tempfp.close() + if py.builtin._istext(data): + data = data.encode("utf8") # XXX use encoding of original stream + os.write(self._savefd, data) def dupfile(f, mode=None, buffering=0, raising=False, encoding=None):