tentatively fix py33 and py25 compat
This commit is contained in:
parent
ac1d277225
commit
d27c377817
|
@ -2,6 +2,8 @@
|
||||||
per-test stdout/stderr capturing mechanism.
|
per-test stdout/stderr capturing mechanism.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from __future__ import with_statement
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
@ -366,12 +368,9 @@ class FDCapture:
|
||||||
def writeorg(self, data):
|
def writeorg(self, data):
|
||||||
""" write a string to the original file descriptor
|
""" write a string to the original file descriptor
|
||||||
"""
|
"""
|
||||||
tempfp = tempfile.TemporaryFile()
|
if py.builtin._istext(data):
|
||||||
try:
|
data = data.encode("utf8") # XXX use encoding of original stream
|
||||||
os.dup2(self._savefd, tempfp.fileno())
|
os.write(self._savefd, data)
|
||||||
tempfp.write(data)
|
|
||||||
finally:
|
|
||||||
tempfp.close()
|
|
||||||
|
|
||||||
|
|
||||||
def dupfile(f, mode=None, buffering=0, raising=False, encoding=None):
|
def dupfile(f, mode=None, buffering=0, raising=False, encoding=None):
|
||||||
|
|
Loading…
Reference in New Issue