benjamin.peterson
2008-10-15 22:28:55 UTC
Author: benjamin.peterson
Date: Thu Oct 16 00:28:54 2008
New Revision: 66909
Log:
use bytes throughout telnetlib docs
Modified:
python/branches/py3k/Doc/library/telnetlib.rst
Modified: python/branches/py3k/Doc/library/telnetlib.rst
==============================================================================
--- python/branches/py3k/Doc/library/telnetlib.rst (original)
+++ python/branches/py3k/Doc/library/telnetlib.rst Thu Oct 16 00:28:54 2008
@@ -62,58 +62,58 @@
.. 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 @@
.. 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 @@
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 @@
tn.write(b"ls\n")
tn.write(b"exit\n")
- print(tn.read_all())
+ print(tn.read_all().decode('ascii'))
Date: Thu Oct 16 00:28:54 2008
New Revision: 66909
Log:
use bytes throughout telnetlib docs
Modified:
python/branches/py3k/Doc/library/telnetlib.rst
Modified: python/branches/py3k/Doc/library/telnetlib.rst
==============================================================================
--- python/branches/py3k/Doc/library/telnetlib.rst (original)
+++ python/branches/py3k/Doc/library/telnetlib.rst Thu Oct 16 00:28:54 2008
@@ -62,58 +62,58 @@
.. 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 @@
.. 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 @@
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 @@
tn.write(b"ls\n")
tn.write(b"exit\n")
- print(tn.read_all())
+ print(tn.read_all().decode('ascii'))