This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix code example in Python 3.5 telnetlib documentation
Type: enhancement Stage:
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Norman Lorrain, docs@python, jackdied, r.david.murray, tiabc
Priority: normal Keywords: easy

Created on 2016-11-10 19:16 by tiabc, last changed 2022-04-11 14:58 by admin.

Files
File name Uploaded Description Edit
weather.py Norman Lorrain, 2021-06-22 18:58
Messages (5)
msg280536 - (view) Author: Ivan Tomilov (tiabc) Date: 2016-11-10 19:16
The code sample on page https://docs.python.org/3/library/telnetlib.html is a little confusing. The extra space in string "Password: " before the second quote basically hangs the example program when you try to run it.

Please, check my answer on Stack Overflow for more details:
http://stackoverflow.com/questions/28345839/python3-telnet-code-stays-quiet-after-launching-does-not-initiate-the-command-t/40535049#40535049

I'm sorry if I get something wrong.

Thanks,
Ivan.
msg280549 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-11-10 23:05
Well, the example code is correct for a typical telnet service running on a unix variant.  That will output a space after the colon, so that the user's input is separated from the colon when they start to type.
msg280563 - (view) Author: Ivan Tomilov (tiabc) Date: 2016-11-11 06:34
I see, thanks for the clarification.
But in my OS X the things are different and I spent about 1 hour trying
this code to take off.
Maybe it's better to change this code to avoid spending time for such
subtle bugs? Say:
tn.read_until(b"Password:")
tn.read_eager()

Or just add a comment. It's confusing when one takes code from the official
website and it doesn't work.

What do you think?

On 11 November 2016 at 02:05, R. David Murray <report@bugs.python.org>
wrote:

>
> R. David Murray added the comment:
>
> Well, the example code is correct for a typical telnet service running on
> a unix variant.  That will output a space after the colon, so that the
> user's input is separated from the colon when they start to type.
>
> ----------
> nosy: +r.david.murray
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue28661>
> _______________________________________
>
msg280586 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2016-11-11 14:55
Hmm.  I'm surprised that OSX would be different.  I didn't actually experiment to confirm it on linux, either.

I could be taken as a "teaching opportunity" to talk about exact match vs read_eager, in a comment before or after the example, if someone wants to propose a doc patch.  I'm not opposed to changing the example, but an explanation would probably be good either way.

Maybe Jack will have an opinion.
msg396357 - (view) Author: Norman Lorrain (Norman Lorrain) * Date: 2021-06-22 18:58
How about a simpler example (this relies on an outside service, fwiw)

See attached file.
History
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72847
2021-06-22 18:58:45Norman Lorrainsetfiles: + weather.py
nosy: + Norman Lorrain
messages: + msg396357

2021-06-21 16:56:24iritkatrielsetkeywords: + easy
versions: + Python 3.9, Python 3.10, Python 3.11, - Python 3.5, Python 3.6, Python 3.7
2016-11-11 14:55:45r.david.murraysetversions: + Python 3.6, Python 3.7
nosy: + jackdied

messages: + msg280586

assignee: docs@python ->
2016-11-11 06:34:37tiabcsetmessages: + msg280563
2016-11-10 23:05:04r.david.murraysetnosy: + r.david.murray
messages: + msg280549
2016-11-10 19:16:31tiabccreate