summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2008-10-15 22:28:54 (GMT)
committerBenjamin Peterson <benjamin@python.org>2008-10-15 22:28:54 (GMT)
commitaaebe1c11d0eccc067cb6e5bb4e28543441fd2df (patch)
tree4687c0112d8d5a57458af42d337f312c68263f84
parent3de7fb86fc9e053955dae144b4fe6e080f5a4d81 (diff)
downloadcpython-aaebe1c11d0eccc067cb6e5bb4e28543441fd2df.zip
cpython-aaebe1c11d0eccc067cb6e5bb4e28543441fd2df.tar.gz
cpython-aaebe1c11d0eccc067cb6e5bb4e28543441fd2df.tar.bz2
use bytes throughout telnetlib docs
-rw-r--r--Doc/library/telnetlib.rst65
1 files changed, 33 insertions, 32 deletions
diff --git a/Doc/library/telnetlib.rst b/Doc/library/telnetlib.rst
index a371e0c..134ddb6 100644
--- a/Doc/library/telnetlib.rst
+++ b/Doc/library/telnetlib.rst
@@ -62,58 +62,58 @@ Telnet Objects
.. method:: Telnet.read_until(expected[, timeout])
- Read until a given string, *expected*, is encountered or until *timeout* seconds
- have passed.
+ Read until a given byte string, *expected*, is encountered or until *timeout*
+ seconds have passed.
- When no match is found, return whatever is available instead, possibly the empty
- string. Raise :exc:`EOFError` if the connection is closed and no cooked data is
- available.
+ When no match is found, return whatever is available instead, possibly empty
+ bytes. Raise :exc:`EOFError` if the connection is closed and no cooked data
+ is available.
.. method:: Telnet.read_all()
- Read all data until EOF; block until connection closed.
+ Read all data until EOF as bytes; block until connection closed.
.. method:: Telnet.read_some()
- Read at least one byte of cooked data unless EOF is hit. Return ``''`` if EOF is
- hit. Block if no data is immediately available.
+ Read at least one byte of cooked data unless EOF is hit. Return ``b''`` if
+ EOF is hit. Block if no data is immediately available.
.. method:: Telnet.read_very_eager()
Read everything that can be without blocking in I/O (eager).
- Raise :exc:`EOFError` if connection closed and no cooked data available. Return
- ``''`` if no cooked data available otherwise. Do not block unless in the midst
- of an IAC sequence.
+ Raise :exc:`EOFError` if connection closed and no cooked data available.
+ Return ``b''`` if no cooked data available otherwise. Do not block unless in
+ the midst of an IAC sequence.
.. method:: Telnet.read_eager()
Read readily available data.
- Raise :exc:`EOFError` if connection closed and no cooked data available. Return
- ``''`` if no cooked data available otherwise. Do not block unless in the midst
- of an IAC sequence.
+ Raise :exc:`EOFError` if connection closed and no cooked data available.
+ Return ``b''`` if no cooked data available otherwise. Do not block unless in
+ the midst of an IAC sequence.
.. method:: Telnet.read_lazy()
Process and return data already in the queues (lazy).
- Raise :exc:`EOFError` if connection closed and no data available. Return ``''``
- if no cooked data available otherwise. Do not block unless in the midst of an
- IAC sequence.
+ Raise :exc:`EOFError` if connection closed and no data available. Return
+ ``b''`` if no cooked data available otherwise. Do not block unless in the
+ midst of an IAC sequence.
.. method:: Telnet.read_very_lazy()
Return any data available in the cooked queue (very lazy).
- Raise :exc:`EOFError` if connection closed and no data available. Return ``''``
- if no cooked data available otherwise. This method never blocks.
+ Raise :exc:`EOFError` if connection closed and no data available. Return
+ ``b''`` if no cooked data available otherwise. This method never blocks.
.. method:: Telnet.read_sb_data()
@@ -163,9 +163,9 @@ Telnet Objects
.. method:: Telnet.write(buffer)
- Write a string to the socket, doubling any IAC characters. This can block if the
- connection is blocked. May raise :exc:`socket.error` if the connection is
- closed.
+ Write a byte string to the socket, doubling any IAC characters. This can
+ block if the connection is blocked. May raise :exc:`socket.error` if the
+ connection is closed.
.. method:: Telnet.interact()
@@ -183,20 +183,21 @@ Telnet Objects
Read until one from a list of a regular expressions matches.
The first argument is a list of regular expressions, either compiled
- (:class:`re.RegexObject` instances) or uncompiled (strings). The optional second
- argument is a timeout, in seconds; the default is to block indefinitely.
+ (:class:`re.RegexObject` instances) or uncompiled (byte strings). The
+ optional second argument is a timeout, in seconds; the default is to block
+ indefinitely.
Return a tuple of three items: the index in the list of the first regular
- expression that matches; the match object returned; and the text read up till
- and including the match.
+ expression that matches; the match object returned; and the bytes read up
+ till and including the match.
- If end of file is found and no text was read, raise :exc:`EOFError`. Otherwise,
- when nothing matches, return ``(-1, None, text)`` where *text* is the text
- received so far (may be the empty string if a timeout happened).
+ If end of file is found and no bytes were read, raise :exc:`EOFError`.
+ Otherwise, when nothing matches, return ``(-1, None, data)`` where *data* is
+ the bytes received so far (may be empty bytes if a timeout happened).
If a regular expression ends with a greedy match (such as ``.*``) or if more
- than one expression can match the same input, the results are indeterministic,
- and may depend on the I/O timing.
+ than one expression can match the same input, the results are
+ indeterministic, and may depend on the I/O timing.
.. method:: Telnet.set_option_negotiation_callback(callback)
@@ -234,5 +235,5 @@ A simple example illustrating typical use::
tn.write(b"ls\n")
tn.write(b"exit\n")
- print(tn.read_all())
+ print(tn.read_all().decode('ascii'))