Remove 'b' from sys.stdout.mode

This commit is contained in:
Anthony Sottile 2019-05-14 14:54:03 -07:00
parent 6a43c8cd94
commit 4318698bae
3 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1 @@
Ensure that ``sys.stdout.mode`` does not include ``'b'`` as it is a text stream.

View File

@ -447,6 +447,10 @@ class EncodedFile(object):
"""Ensure that file.name is a string."""
return repr(self.buffer)
@property
def mode(self):
return self.buffer.mode.replace("b", "")
def __getattr__(self, name):
return getattr(object.__getattribute__(self, "buffer"), name)

View File

@ -1051,6 +1051,9 @@ class TestFDCapture(object):
cap.done()
pytest.raises(AttributeError, cap.suspend)
def test_capfd_sys_stdout_mode(self, capfd):
assert "b" not in sys.stdout.mode
@contextlib.contextmanager
def saved_fd(fd):