@@ -62,58 +62,58 @@ Telnet Objects
6262
6363.. method :: Telnet.read_until(expected[, timeout])
6464
65- Read until a given string, *expected *, is encountered or until *timeout * seconds
66- have passed.
65+ Read until a given byte string, *expected *, is encountered or until *timeout *
66+ seconds have passed.
6767
68- When no match is found, return whatever is available instead, possibly the empty
69- string . Raise :exc: `EOFError ` if the connection is closed and no cooked data is
70- available.
68+ When no match is found, return whatever is available instead, possibly empty
69+ bytes . Raise :exc: `EOFError ` if the connection is closed and no cooked data
70+ is available.
7171
7272
7373.. method :: Telnet.read_all()
7474
75- Read all data until EOF; block until connection closed.
75+ Read all data until EOF as bytes ; block until connection closed.
7676
7777
7878.. method :: Telnet.read_some()
7979
80- Read at least one byte of cooked data unless EOF is hit. Return ``'' `` if EOF is
81- hit. Block if no data is immediately available.
80+ Read at least one byte of cooked data unless EOF is hit. Return ``b '' `` if
81+ EOF is hit. Block if no data is immediately available.
8282
8383
8484.. method :: Telnet.read_very_eager()
8585
8686 Read everything that can be without blocking in I/O (eager).
8787
88- Raise :exc: `EOFError ` if connection closed and no cooked data available. Return
89- `` '' `` if no cooked data available otherwise. Do not block unless in the midst
90- of an IAC sequence.
88+ Raise :exc: `EOFError ` if connection closed and no cooked data available.
89+ Return `` b '' `` if no cooked data available otherwise. Do not block unless in
90+ the midst of an IAC sequence.
9191
9292
9393.. method :: Telnet.read_eager()
9494
9595 Read readily available data.
9696
97- Raise :exc: `EOFError ` if connection closed and no cooked data available. Return
98- `` '' `` if no cooked data available otherwise. Do not block unless in the midst
99- of an IAC sequence.
97+ Raise :exc: `EOFError ` if connection closed and no cooked data available.
98+ Return `` b '' `` if no cooked data available otherwise. Do not block unless in
99+ the midst of an IAC sequence.
100100
101101
102102.. method :: Telnet.read_lazy()
103103
104104 Process and return data already in the queues (lazy).
105105
106- Raise :exc: `EOFError ` if connection closed and no data available. Return `` '' ``
107- if no cooked data available otherwise. Do not block unless in the midst of an
108- IAC sequence.
106+ Raise :exc: `EOFError ` if connection closed and no data available. Return
107+ `` b'' `` if no cooked data available otherwise. Do not block unless in the
108+ midst of an IAC sequence.
109109
110110
111111.. method :: Telnet.read_very_lazy()
112112
113113 Return any data available in the cooked queue (very lazy).
114114
115- Raise :exc: `EOFError ` if connection closed and no data available. Return `` '' ``
116- if no cooked data available otherwise. This method never blocks.
115+ Raise :exc: `EOFError ` if connection closed and no data available. Return
116+ `` b'' `` if no cooked data available otherwise. This method never blocks.
117117
118118
119119.. method :: Telnet.read_sb_data()
@@ -163,9 +163,9 @@ Telnet Objects
163163
164164.. method :: Telnet.write(buffer)
165165
166- Write a string to the socket, doubling any IAC characters. This can block if the
167- connection is blocked. May raise :exc: `socket.error ` if the connection is
168- closed.
166+ Write a byte string to the socket, doubling any IAC characters. This can
167+ block if the connection is blocked. May raise :exc: `socket.error ` if the
168+ connection is closed.
169169
170170
171171.. method :: Telnet.interact()
@@ -183,20 +183,21 @@ Telnet Objects
183183 Read until one from a list of a regular expressions matches.
184184
185185 The first argument is a list of regular expressions, either compiled
186- (:class: `re.RegexObject ` instances) or uncompiled (strings). The optional second
187- argument is a timeout, in seconds; the default is to block indefinitely.
186+ (:class: `re.RegexObject ` instances) or uncompiled (byte strings). The
187+ optional second argument is a timeout, in seconds; the default is to block
188+ indefinitely.
188189
189190 Return a tuple of three items: the index in the list of the first regular
190- expression that matches; the match object returned; and the text read up till
191- and including the match.
191+ expression that matches; the match object returned; and the bytes read up
192+ till and including the match.
192193
193- If end of file is found and no text was read, raise :exc: `EOFError `. Otherwise,
194- when nothing matches, return ``(-1, None, text ) `` where *text * is the text
195- received so far (may be the empty string if a timeout happened).
194+ If end of file is found and no bytes were read, raise :exc: `EOFError `.
195+ Otherwise, when nothing matches, return ``(-1, None, data ) `` where *data * is
196+ the bytes received so far (may be empty bytes if a timeout happened).
196197
197198 If a regular expression ends with a greedy match (such as ``.* ``) or if more
198- than one expression can match the same input, the results are indeterministic,
199- and may depend on the I/O timing.
199+ than one expression can match the same input, the results are
200+ indeterministic, and may depend on the I/O timing.
200201
201202
202203.. method :: Telnet.set_option_negotiation_callback(callback)
@@ -234,5 +235,5 @@ A simple example illustrating typical use::
234235 tn.write(b"ls\n")
235236 tn.write(b"exit\n")
236237
237- print(tn.read_all())
238+ print(tn.read_all().decode('ascii') )
238239
0 commit comments