aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'py/_io/capture.py')
-rw-r--r--py/_io/capture.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/py/_io/capture.py b/py/_io/capture.py
index 59bdf0b2e2..e558b80034 100644
--- a/py/_io/capture.py
+++ b/py/_io/capture.py
@@ -12,7 +12,7 @@ if sys.version_info < (3,0):
class TextIO(StringIO):
def write(self, data):
if not isinstance(data, unicode):
- data = unicode(data, getattr(self, '_encoding', 'UTF-8'))
+ data = unicode(data, getattr(self, '_encoding', 'UTF-8'), 'replace')
StringIO.write(self, data)
else:
TextIO = StringIO
@@ -260,7 +260,7 @@ class StdCaptureFD(Capture):
res = f.read()
enc = getattr(f, 'encoding', None)
if enc:
- res = py.builtin._totext(res, enc)
+ res = py.builtin._totext(res, enc, 'replace')
f.truncate(0)
f.seek(0)
l.append(res)