mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
use bytes throughout telnetlib docs
This commit is contained in:
parent
3de7fb86fc
commit
aaebe1c11d
1 changed files with 33 additions and 32 deletions
|
|
@ -62,58 +62,58 @@ Telnet Objects
|
||||||
|
|
||||||
.. method:: Telnet.read_until(expected[, timeout])
|
.. method:: Telnet.read_until(expected[, timeout])
|
||||||
|
|
||||||
Read until a given string, *expected*, is encountered or until *timeout* seconds
|
Read until a given byte string, *expected*, is encountered or until *timeout*
|
||||||
have passed.
|
seconds have passed.
|
||||||
|
|
||||||
When no match is found, return whatever is available instead, possibly the empty
|
When no match is found, return whatever is available instead, possibly empty
|
||||||
string. Raise :exc:`EOFError` if the connection is closed and no cooked data is
|
bytes. Raise :exc:`EOFError` if the connection is closed and no cooked data
|
||||||
available.
|
is available.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_all()
|
.. 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()
|
.. method:: Telnet.read_some()
|
||||||
|
|
||||||
Read at least one byte of cooked data unless EOF is hit. Return ``''`` if EOF is
|
Read at least one byte of cooked data unless EOF is hit. Return ``b''`` if
|
||||||
hit. Block if no data is immediately available.
|
EOF is hit. Block if no data is immediately available.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_very_eager()
|
.. method:: Telnet.read_very_eager()
|
||||||
|
|
||||||
Read everything that can be without blocking in I/O (eager).
|
Read everything that can be without blocking in I/O (eager).
|
||||||
|
|
||||||
Raise :exc:`EOFError` if connection closed and no cooked data available. Return
|
Raise :exc:`EOFError` if connection closed and no cooked data available.
|
||||||
``''`` if no cooked data available otherwise. Do not block unless in the midst
|
Return ``b''`` if no cooked data available otherwise. Do not block unless in
|
||||||
of an IAC sequence.
|
the midst of an IAC sequence.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_eager()
|
.. method:: Telnet.read_eager()
|
||||||
|
|
||||||
Read readily available data.
|
Read readily available data.
|
||||||
|
|
||||||
Raise :exc:`EOFError` if connection closed and no cooked data available. Return
|
Raise :exc:`EOFError` if connection closed and no cooked data available.
|
||||||
``''`` if no cooked data available otherwise. Do not block unless in the midst
|
Return ``b''`` if no cooked data available otherwise. Do not block unless in
|
||||||
of an IAC sequence.
|
the midst of an IAC sequence.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_lazy()
|
.. method:: Telnet.read_lazy()
|
||||||
|
|
||||||
Process and return data already in the queues (lazy).
|
Process and return data already in the queues (lazy).
|
||||||
|
|
||||||
Raise :exc:`EOFError` if connection closed and no data available. Return ``''``
|
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
|
``b''`` if no cooked data available otherwise. Do not block unless in the
|
||||||
IAC sequence.
|
midst of an IAC sequence.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_very_lazy()
|
.. method:: Telnet.read_very_lazy()
|
||||||
|
|
||||||
Return any data available in the cooked queue (very lazy).
|
Return any data available in the cooked queue (very lazy).
|
||||||
|
|
||||||
Raise :exc:`EOFError` if connection closed and no data available. Return ``''``
|
Raise :exc:`EOFError` if connection closed and no data available. Return
|
||||||
if no cooked data available otherwise. This method never blocks.
|
``b''`` if no cooked data available otherwise. This method never blocks.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.read_sb_data()
|
.. method:: Telnet.read_sb_data()
|
||||||
|
|
@ -163,9 +163,9 @@ Telnet Objects
|
||||||
|
|
||||||
.. method:: Telnet.write(buffer)
|
.. method:: Telnet.write(buffer)
|
||||||
|
|
||||||
Write a string to the socket, doubling any IAC characters. This can block if the
|
Write a byte string to the socket, doubling any IAC characters. This can
|
||||||
connection is blocked. May raise :exc:`socket.error` if the connection is
|
block if the connection is blocked. May raise :exc:`socket.error` if the
|
||||||
closed.
|
connection is closed.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.interact()
|
.. method:: Telnet.interact()
|
||||||
|
|
@ -183,20 +183,21 @@ Telnet Objects
|
||||||
Read until one from a list of a regular expressions matches.
|
Read until one from a list of a regular expressions matches.
|
||||||
|
|
||||||
The first argument is a list of regular expressions, either compiled
|
The first argument is a list of regular expressions, either compiled
|
||||||
(:class:`re.RegexObject` instances) or uncompiled (strings). The optional second
|
(:class:`re.RegexObject` instances) or uncompiled (byte strings). The
|
||||||
argument is a timeout, in seconds; the default is to block indefinitely.
|
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
|
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
|
expression that matches; the match object returned; and the bytes read up
|
||||||
and including the match.
|
till and including the match.
|
||||||
|
|
||||||
If end of file is found and no text was read, raise :exc:`EOFError`. Otherwise,
|
If end of file is found and no bytes were read, raise :exc:`EOFError`.
|
||||||
when nothing matches, return ``(-1, None, text)`` where *text* is the text
|
Otherwise, when nothing matches, return ``(-1, None, data)`` where *data* is
|
||||||
received so far (may be the empty string if a timeout happened).
|
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
|
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,
|
than one expression can match the same input, the results are
|
||||||
and may depend on the I/O timing.
|
indeterministic, and may depend on the I/O timing.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Telnet.set_option_negotiation_callback(callback)
|
.. 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"ls\n")
|
||||||
tn.write(b"exit\n")
|
tn.write(b"exit\n")
|
||||||
|
|
||||||
print(tn.read_all())
|
print(tn.read_all().decode('ascii'))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue