summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-06-14 18:41:18 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-06-14 18:41:18 (GMT)
commit995bb47c1729bb7e62649c5697f5e148e0ec591f (patch)
tree7909a91044d4d672c7a8acc0ee8020da65df4bc2 /Doc
parent6a38ceda034df6b0be6ed41edbdc28f76e7e7805 (diff)
downloadcpython-995bb47c1729bb7e62649c5697f5e148e0ec591f.zip
cpython-995bb47c1729bb7e62649c5697f5e148e0ec591f.tar.gz
cpython-995bb47c1729bb7e62649c5697f5e148e0ec591f.tar.bz2
rewrite binary std streams part; note that detach()/buffer will not always work
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/sys.rst11
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 1278a7c..ba22dc3 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -784,13 +784,18 @@ always available.
The standard streams are in text mode by default. To write or read binary
data to these, use the underlying binary buffer. For example, to write bytes
to :data:`stdout`, use ``sys.stdout.buffer.write(b'abc')``. Using
- :meth:`io.TextIOBase.detach` streams can be made binary by default. For
- example, this function sets all the standard streams to binary::
+ :meth:`io.TextIOBase.detach` streams can be made binary by default. This
+ function sets :data:`stdin` and :data:`stdout` to binary::
def make_streams_binary():
sys.stdin = sys.stdin.detach()
sys.stdout = sys.stdout.detach()
- sys.stderr = sys.stderr.detach()
+
+ Note that the streams can be replaced with objects (like
+ :class:`io.StringIO`) that do not support the
+ :attr:`~io.BufferedIOBase.buffer` attribute or the
+ :meth:`~io.BufferedIOBase.detach` method and can raise :exc:`AttributeError`
+ or :exc:`io.UnsupportedOperation`.
.. data:: __stdin__