Commits

Ronny Pfannschmidt  committed 005a5e2

patch updates

  • Participants
  • Parent commits 587e5aa

Comments (0)

Files changed (1)

File capture-bytes

 # HG changeset patch
-# Parent adc36f84f7808d61558cf399c3b205f2adf18417
+# Parent 0e9b0af624e13e1cbb3cd7a058a20722c6c89cdc
 use the replace handler for stray bytes on stdout/err capture
 
 diff --git a/py/_io/capture.py b/py/_io/capture.py
              StringIO.write(self, data)
  else:
      TextIO = StringIO
-@@ -259,8 +259,9 @@ class StdCaptureFD(Capture):
-                 f.seek(0)
+@@ -260,7 +260,7 @@ class StdCaptureFD(Capture):
                  res = f.read()
                  enc = getattr(f, 'encoding', None)
-+                print enc
                  if enc:
 -                    res = py.builtin._totext(res, enc)
 +                    res = py.builtin._totext(res, enc, 'replace')
 diff --git a/testing/io_/test_capture.py b/testing/io_/test_capture.py
 --- a/testing/io_/test_capture.py
 +++ b/testing/io_/test_capture.py
-@@ -219,6 +219,12 @@ class TestStdCapture:
+@@ -219,6 +219,15 @@ class TestStdCapture:
          out, err = cap.readouterr()
          assert out == py.builtin._totext("hx\xc4\x85\xc4\x87\n", "utf8")
  
++    @py.test.mark.skipif('sys.version_info >= (3,)',
++                      reason='text output different for bytes on python3')
 +    def test_capturing_readouterr_decode_error_handling(self):
 +        cap = self.getcapture()
 +        # triggered a internal error in pytest
 +        print('\xa6')
 +        out, err = cap.readouterr()
++        assert out == py.builtin._totext('\ufffd\n', 'unicode-escape')
 +
      def test_capturing_mixed(self):
          cap = self.getcapture(mixed=True)