be more robust about bad std stream encodings
--HG-- branch : trunk
This commit is contained in:
parent
d93016d85f
commit
78d67c007b
|
@ -296,12 +296,14 @@ class TmpTestdir:
|
||||||
f2.close()
|
f2.close()
|
||||||
out = p1.read("rb").decode("utf-8").splitlines()
|
out = p1.read("rb").decode("utf-8").splitlines()
|
||||||
err = p2.read("rb").decode("utf-8").splitlines()
|
err = p2.read("rb").decode("utf-8").splitlines()
|
||||||
if err:
|
def dump_lines(lines, fp):
|
||||||
for line in err:
|
try:
|
||||||
py.builtin.print_(line, file=sys.stderr)
|
for line in lines:
|
||||||
if out:
|
py.builtin.print_(line, file=fp)
|
||||||
for line in out:
|
except UnicodeEncodeError:
|
||||||
py.builtin.print_(line, file=sys.stdout)
|
print("couldn't print to %s because of encoding" % (fp,))
|
||||||
|
dump_lines(out, sys.stdout)
|
||||||
|
dump_lines(err, sys.stderr)
|
||||||
return RunResult(ret, out, err, time.time()-now)
|
return RunResult(ret, out, err, time.time()-now)
|
||||||
|
|
||||||
def runpybin(self, scriptname, *args):
|
def runpybin(self, scriptname, *args):
|
||||||
|
|
Loading…
Reference in New Issue