Problems with telnetlib
Sheila King
usenet at thinkspot.net
Sat Feb 16 09:46:39 EST 2002
On 16 Feb 2002 13:56:35 +0100, Jan-Fredrik Braseth
<janfbr at sex.ifi.uio.no> wrote in comp.lang.python in article
<xyuvgcxlh4s.fsf at sex.ifi.uio.no>:
> but after some time I get this error message:
>
> Traceback (most recent call last):
> File "./quizbot.py", line 366, in ?
> foo = QuizBot(name,password,channel)
> File "./quizbot.py", line 28, in __init__
> line = self.tn.read_until("\n").split()
> File "/usr/lib/python2.2/telnetlib.py", line 297, in read_until
> self.process_rawq()
> File "/usr/lib/python2.2/telnetlib.py", line 424, in process_rawq
> self.msg('IAC %d not recognized' % ord(opt))
> UnboundLocalError: local variable 'opt' referenced before assignment
>
> The main loop of the bot is just a while(1) which reads a line at the
> time from the connection: line =self.tn.read_until("\n").split()
> and it looks like this fails after some time.
>
> tn is initiated like this:
>
> tn = telnetlib.Telnet(server,port)
>
> I really hope someone can help me with this problem
You have an error in your code. Show us the code. I'm guessing, that you
have a variable 'opt' that under some circumstances is not defined
before entering a particular loop or something.
--
Sheila King
http://www.thinkspot.net/sheila/
"When introducing your puppy to an adult cat,
restrain the puppy, not the cat." -- Gwen Bailey,
_The Perfect Puppy: How to Raise a Well-behaved Dog_
More information about the Python-list
mailing list