classification
Title: read_until
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jackdied Nosy List: irczan, jackdied, ps
Priority: normal Keywords:

Created on 2009-05-25 16:13 by ps, last changed 2009-07-27 09:05 by jackdied. This issue is now closed.

Files
File name Uploaded Description Edit
telnet_n.py ps, 2009-05-25 16:13 telnet example with read_until not working
Messages (8)
msg88319 - (view) Author: Pal Subbiah (ps) Date: 2009-05-25 16:13
The telnet-read_until does not read the pattern and returns b'' for 
line 15 in the file given.
msg88398 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-05-26 22:40
Try using telnetlib.py from python3.1.  It fixes issues in telnet out of
band negotiations.  

http://svn.python.org/projects/python/branches/py3k/Lib/telnetlib.py

Here is what I think is happening:
HOST: b'User' + IAC + ECHO + DONT + b'name:\nPassword\n:'
read_until: times out on Username match, returns all HOST text so far.
You: *send username*
HOST: >
read_until: times out on Password match, returns '>'
You: *send password*
read_until: times out on '>' match, returns ''

This is the only way I could repeat the problem using a local Echo server.

Please let me know if using the telnetlib.py from 3.1 works for you.
msg88421 - (view) Author: Pal Subbiah (ps) Date: 2009-05-27 15:31
Thanks for your support.
But the telnetlib from 3.1 also behaves in the same way. "read_until" 
always times out and returns b''. The problem seems to be with the byte 
string expected. The string after letter b is not passed properly.
msg90845 - (view) Author: Irek Wlizlo (irczan) Date: 2009-07-23 13:52
Hi, 
I head same problem on 3.0 and 3.1 versions
This was because of incompatibility of types in comparison 

My solution is to modify 
Lib/telnetlib.py   
line  462
cmd = self.iacseq[1]
 to 
cmd = self.iacseq[1:2]

Irek
msg90849 - (view) Author: Pal Subbiah (ps) Date: 2009-07-23 16:44
Thanks Irek. It works so well now after I modified the telnetlib.py as
you suggested. I also added decode('ascii') with read_until.

Pal Subbiah
msg90962 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-07-26 22:26
fixed in r74217

My thanks to everyone who contributed to this bug.  "irek" if you let me
know your name I'll add it to Misc/ACKS as well.

PS, The additional testcase is not ideal;  it tests the bad behavior by
hooking into the debug output instead of testing the bug directly.
msg90977 - (view) Author: Irek Wlizlo (irczan) Date: 2009-07-27 07:22
Hi,
I updated my profile with name - Irek Wlizlo
msg90979 - (view) Author: Jack Diederich (jackdied) * (Python committer) Date: 2009-07-27 09:05
Thanks for the update Irek (and the help!). You are now listed in Misc/ACKS.
History
Date User Action Args
2009-07-27 09:05:50jackdiedsetmessages: + msg90979
2009-07-27 07:22:35irczansetmessages: + msg90977
2009-07-26 22:26:17jackdiedsetstatus: open -> closed
resolution: fixed
messages: + msg90962
2009-07-23 16:44:45pssetmessages: + msg90849
2009-07-23 13:52:41irczansetnosy: + irczan

messages: + msg90845
versions: + Python 3.1
2009-05-27 15:31:45pssetmessages: + msg88421
2009-05-26 22:40:53jackdiedsettype: crash -> behavior
2009-05-26 22:40:26jackdiedsetmessages: + msg88398
2009-05-25 17:12:47benjamin.petersonsetassignee: jackdied

nosy: + jackdied
2009-05-25 16:13:03pscreate