Merge pull request #5262 from asottile/mode_non_binary

Remove 'b' from sys.stdout.mode
This commit is contained in:
Daniel Hahler 2019-05-15 10:56:36 +02:00 committed by GitHub
commit c8f7e50c47
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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):